gskurski Posted May 18, 2010 Share Posted May 18, 2010 I'm having a problem which I'm sure will take a simple fix, but I can't seem to figure it out. I have a form now that lets you pick from six different options and then submit it to a redirect php file. In the php file I have an if, else if statement that is suppose to redirect to different pages corresponding to the original value selected in the form. Here is my code. <form action="subredirect.php" method="post" target="index"> <select name="redirect"> <option value="vodka">Vodkas</option> <option value="bourbons">Bourbons</option> <option value="rum">Rums</option> <option value="gin">Gins</option> <option value="brandy">Brandy</option> <option value="tequila">Tequila</option> <option value="whiskey">Whiskey</option> </select> <input type="submit" value="Go!"> </form> And here is my php file <?php if ($_POST(['redirect'])== "vodka"){ header("Location: http://www.website.com/vodkasubmit.php"); exit (); } elseif ($_POST(['redirect'])== "bourbon"){ header("Location: http://www.website.com/bourbonsubmit.php"); exit (); } elseif ($_POST(['redirect'])== "rum"){ header("_POST(['redirect']): http://www.website.com/rumsubmit.php"); exit (); } elseif ($_POST(['redirect'])== "gins"){ header("Location: http://www.website.com/ginsubmit.php"); exit (); } elseif ($_POST(['redirect'])== "brandy"){ header("Location: http://www.website.com/brandysubmit.php"); exit (); } elseif ($_POST(['redirect'])== "tequila"){ header("Location: http://www.website.com/tequilasubmit.php"); exit (); } elseif ($_POST(['redirect'])== "whiskey"){ header("Location: http://www.website.com/whiskeysubmit.php"); exit (); } ?> Any help is really appreciated! Thanks -Gerry Link to comment https://forums.phpfreaks.com/topic/202181-form-submission-re-direct-problem/ Share on other sites More sharing options...
gskurski Posted May 18, 2010 Author Share Posted May 18, 2010 I forgot to mention the problem, which is simply that when I click "Go!", it won't load to any of the specified pages. Link to comment https://forums.phpfreaks.com/topic/202181-form-submission-re-direct-problem/#findComment-1060176 Share on other sites More sharing options...
hcdarkmage Posted May 18, 2010 Share Posted May 18, 2010 Try this: <?php if (isset($_POST['redirect'])){ header("Location: http://www.website.com/".$_POST['redirect']."submit.php"); exit(); } ?> <form method="post" action=""> <select name="redirect"> <option value="vodka">Vodkas</option> <option value="bourbons">Bourbons</option> <option value="rum">Rums</option> <option value="gin">Gins</option> <option value="brandy">Brandy</option> <option value="tequila">Tequila</option> <option value="whiskey">Whiskey</option> </select> <input type="submit" value="Go!"> </form> Link to comment https://forums.phpfreaks.com/topic/202181-form-submission-re-direct-problem/#findComment-1060180 Share on other sites More sharing options...
gskurski Posted May 18, 2010 Author Share Posted May 18, 2010 That worked perfectly, thanks so much! Link to comment https://forums.phpfreaks.com/topic/202181-form-submission-re-direct-problem/#findComment-1060183 Share on other sites More sharing options...
hcdarkmage Posted May 18, 2010 Share Posted May 18, 2010 Don't forget to mark the thread as solved. Link to comment https://forums.phpfreaks.com/topic/202181-form-submission-re-direct-problem/#findComment-1060184 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.