JoeLongstreet Posted November 11, 2008 Share Posted November 11, 2008 I'm trying to use this little piece of code to direct a user to another page on the site. If they select a specific dropdown they should go to one section and if they select a different dropdown, they should go to another. From my feeble understanding of php I think this should work. Why doesn't it? <?php if(isset($_POST['submit'])) { $to = "[email protected]"; $subject = "New Download requested from JenningsPR.net"; $name_field = $_POST['name']; $email_field = $_POST['email']; $company_field = $_POST['company']; $dropdown = $_POST['drop_down']; $body = "Download Requested: $dropdown\n Name: $name_field\n Company: $company_field\n E-Mail: $email_field\n"; mail($to, $subject, $body); if ($dropdown == metro) { header('Location: http://testing.jenningspr.net/downloads/metro.html'); } else if($dropdown == fittyWest) { header('Location: http://www.jenningspr.net/downloads/fiftyWest.html'); } else if($dropdown == heartland) { header('Location: http://www.jenningspr.net/downloads/heartland.html'); } else if($dropdown == kcdma) { header('Location: http://www.jenningspr.net/downloads/kcdma.html'); } } else { echo "blarg!"; } ?> <fieldset> <legend>Download a Case Study</legend> <form action="caseStudies.php" method="POST"> <table cellspacing="10"> <tr> <td>Case Study:</td> <td> <select name="drop_down"> <option name="metro">Metropolitan</option> <option name="fittyWest">50West</option> <option name="heartland">HeartlandCremation</option> <option name="kcdma">KCDMA</option> </select> </td> </tr> <tr> <td>Name:</td> <td><input name="name" type="text" size="33"/></td> </tr> <tr> <td>Email:</td> <td><input name="email" type="text" size="33"/></td> </tr> <tr> <td>Company:</td> <td><input name="comapny" type="text" size="33"/></td> </tr> <tr> <td></td> <td><input name="submit" value="Submit" type="submit" /></td> </tr> </table> </form> </fieldset> Link to comment https://forums.phpfreaks.com/topic/132305-newbie-using-headers/ Share on other sites More sharing options...
Porl123 Posted November 11, 2008 Share Posted November 11, 2008 <option name="metro">Metropolitan</option> Should be <option value="metro">Metropolitan</option> Link to comment https://forums.phpfreaks.com/topic/132305-newbie-using-headers/#findComment-687856 Share on other sites More sharing options...
DarkWater Posted November 11, 2008 Share Posted November 11, 2008 Also, use quotation marks (" ") around strings when testing them in PHP. if ($dropdown == "metro") { Link to comment https://forums.phpfreaks.com/topic/132305-newbie-using-headers/#findComment-687913 Share on other sites More sharing options...
JoeLongstreet Posted November 11, 2008 Author Share Posted November 11, 2008 Great. Thank you for your help. I appreciate it, Joe Link to comment https://forums.phpfreaks.com/topic/132305-newbie-using-headers/#findComment-688003 Share on other sites More sharing options...
haku Posted November 12, 2008 Share Posted November 12, 2008 Also, use quotation marks (" ") around strings when testing them in PHP. Single quotes are fine. And actually, to get a little technical, single quotes will process faster than double quotes. The reason being that text in double quotes is parsed for variables inside, and text in single quotes is not. Although when it comes down to it, this difference is so marginal as to not even really matter (when outputting a string 400 000 times using each method, the difference was only 5 seconds). Link to comment https://forums.phpfreaks.com/topic/132305-newbie-using-headers/#findComment-688273 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.