Reputation: 6862
What I want to do is have an HTML drop down for example:
<option value="">Select Tire Brand</option>
<option value="cooper">Cooper</option>
<option value="michelin">Michelin</option>
And when they click the Submit button, I want it to go to http://www.domain.com/{selection}/
so if they selected Cooper it would go to http://www.domain.com/cooper/.
I would use the GET method and have it go to the main URL which is brand_results.php?brand=cooper but then the URL wouldn't show up as the neat URL which I use htaccess for.
Is there a way to do what I am looking for?
Thank you!
Upvotes: 1
Views: 1782
Reputation: 24661
I am assuming the value of name for your <select>
is mySelect
below.
After submission:
<?php
if(empty($_POST['mySelect'])) {
// User did not select a brand
}
header('Location: http://www.domain.com/' . urlencode($_POST['mySelect']));
exit();
?>
Upvotes: 3
Reputation: 33901
In the file that receives the result:
header("Location: http://domain.com/".$_GET['brand']);
exit();
Upvotes: 2