IF statement in button or new php??
Posted: Sun Jan 02, 2011 8:57 am
hi again, having trouble getting the result from the drop down box to direct to another page
the if statement works when i don't try and do anything with it.
should the IF statement go on another page and the submit button POST the $result, i'm really not sure. any help would be great..
code so far
index.php
dd-check.php
the if statement works when i don't try and do anything with it.
should the IF statement go on another page and the submit button POST the $result, i'm really not sure. any help would be great..
code so far
index.php
Code: Select all
<?php
$query = "SELECT * FROM `ride` ORDER BY name";
$result = mysql_query($query);
echo"<select name='name'><option value=''>Select Ride</option>";
while( $row = mysql_fetch_array($result) )
{
echo '<option>'.$row['name'].'</option>';
}
echo '</select>';
mysql_free_result( $result );
//// do rest of form when done/////
echo "<form method=post name=f1 action='dd-check.php'>";
echo "<input type=submit value=Submit>";
echo "</form>";
?>
Code: Select all
<?php
$result =$_POST['WHAT GOES HERE?']; <-----------???? is this even needed?
echo "Ride Choosen = $result"; <-----------???? how do i get the $result from index.php?
if ($result == "Swinging Ship") {
header('Location: Swing.php');
} elseif ($result == "Roller Coaster") {
header('Location: Roller.php');
} elseif ($result == "Ice Blast") {
header('Location: Ice.php');
} else {
echo "choose a ride";
}
?>