tjverge Posted January 8, 2011 Share Posted January 8, 2011 The below code should take you to a different page depending on what you choice in the drop down, but all the results only take you to the first on even when you put a different option in the drop down, any ideas? <?php ob_start(); session_start(); $pagerank=1; if ($rank < $pagerank){ header('Location:main.php?id=lowrank.php'); } else{ ?> <form action="main.php?id=search.php" method="post"> <table width="725" border="0" cellspacing="1" cellpadding="1"> <tr> <td width="228">Name: <input name="name" type="text" /></td> <td width="490"><select name="type"> <option>All</option> <option>Alliance</option> <option>Corporation</option> <option>Pilot Name</option> <option>Ship Name</option> <option>Ship Type</option> <option>System Name</option> <option>System Type</option> </select></td> </tr> <tr> <td></td> <td><input name="Submit" type="Submit" /></td> </tr> </table> </form> <?php if (isset($_POST['Submit'])) { $name = $_POST['name']; $type = $_POST['type']; if ($type = "System Name" OR "System Type") { header('Location:main.php?id=searchsystem.php'); exit; } Elseif ($type = "All") { header('Location:main.php?id=searchall.php'); exit; } Else { header('Location:main.php?id=searchpilot.php'); } } } ?> Link to comment https://forums.phpfreaks.com/topic/223739-ifelseif-else-not-working/ Share on other sites More sharing options...
Pikachu2000 Posted January 8, 2011 Share Posted January 8, 2011 All of your <option> tags are missing their value= attributes. Link to comment https://forums.phpfreaks.com/topic/223739-ifelseif-else-not-working/#findComment-1156511 Share on other sites More sharing options...
tjverge Posted January 8, 2011 Author Share Posted January 8, 2011 All of your <option> tags are missing their value= attributes. So I added the attributes <select name="type"> <option value="All">All</option> <option value="Alliance">Alliance</option> <option vaule="Corporation">Corporation</option> <option vaule="Pilot Name">Pilot Name</option> <option vaule="Ship Name">Ship Name</option> <option vaule="Ship Type">Ship Type</option> <option value="System Name">System Name</option> <option value="System Type">System Type</option> </select> but it still has the same result Link to comment https://forums.phpfreaks.com/topic/223739-ifelseif-else-not-working/#findComment-1156512 Share on other sites More sharing options...
BlueSkyIS Posted January 8, 2011 Share Posted January 8, 2011 $type = "System Name" is assignment. $type == "System Name" is comparison. Link to comment https://forums.phpfreaks.com/topic/223739-ifelseif-else-not-working/#findComment-1156515 Share on other sites More sharing options...
tjverge Posted January 8, 2011 Author Share Posted January 8, 2011 $type = "System Name" is assignment. $type == "System Name" is comparison. Updated still only going to the searchsystem.php if ($type == "System Name" OR "System Type") { header('Location:main.php?id=searchsystem.php'); exit; } Elseif ($type == "All") { header('Location:main.php?id=searchall.php'); exit; } Else { header('Location:main.php?id=searchpilot.php'); } Link to comment https://forums.phpfreaks.com/topic/223739-ifelseif-else-not-working/#findComment-1156516 Share on other sites More sharing options...
tjverge Posted January 8, 2011 Author Share Posted January 8, 2011 Fixed it thanks for all the help if ($type == "System Name" OR "System Type") { need to be if ($type == "System Name" OR $type == "System Type") { Link to comment https://forums.phpfreaks.com/topic/223739-ifelseif-else-not-working/#findComment-1156518 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.