Jump to content

if..elseif.. else not working


tjverge

Recommended Posts

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
Share on other sites

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
Share on other sites

$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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.