Simple 2 field form: routing option values to unique urls. How to?

Sonny Forelli

Well-known member
May 8, 2008
2,330
89
48
Liberty City
Wondering if someone could help me out.

I have a very simple form - email and product selection and all I'm trying to do is figure out an easy way to route 3 different option values for product to 3 unique urls.

That is- I can't easily have it just drop to a standard form action of
Code:
http://www.mydomain.com/results.php?option1=selectedproduct1

but instead need to have it go to something like:

http://www.mydomain.com/selectedproduct1.php


(for option 2)

http://www.mydomain.com/selectedproduct2.php  etc
So that I can easily/simply feature the respective product selections on that page.

Can anyone help me with this?
 


can't you just have it submit to a php page, that just redirects to the correct page, depending on option?

if(option1) { redirect to option1.php } etc
 
You're probably set already but I just did this because I'm bored. You would modify this to fit your form values of course and then post to this script...

Code:
<?php

if($_GET['product'] === 'option1') {
 header('Location: http://www.mydomain.com/whateveryouwant.html');
}

if($_GET['product'] === 'option2') {
 header('Location: http://www.mydomain.com/option2pagemaybe.html');
}

if($_GET['product'] === 'option3') {
 header('Location: http://www.mydomain.com/anotheruniquepage.html');
}

else {
 header('Location: http://www.mydomain.com/genericpage.html');
}

?>