jsk1gcc Posted January 2, 2011 Share Posted January 2, 2011 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 <?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>"; ?> dd-check.php <?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"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/223199-if-statement-in-button-or-new-php/ Share on other sites More sharing options...
kenrbnsn Posted January 2, 2011 Share Posted January 2, 2011 Your form is not correct, since the drop down list is outside the form definition. Try something like this: <?php echo '<form method="post" name="f1" action="dd-check.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>'; //// do rest of form when done///// echo "<input type='submit' value='Submit'>"; echo "</form>"; ?> In the processing script: <?php $result =$_POST['name']; echo "Ride Choosen = $result"; // // etc... // ?> Ken Quote Link to comment https://forums.phpfreaks.com/topic/223199-if-statement-in-button-or-new-php/#findComment-1153858 Share on other sites More sharing options...
jsk1gcc Posted January 2, 2011 Author Share Posted January 2, 2011 Thankyou, It's messed up how strict and loose php can be, order is everything in this language. Once I get used to it, i'll be fine untill then i'll keep asking for help and learning Thanks again for a quick reply Quote Link to comment https://forums.phpfreaks.com/topic/223199-if-statement-in-button-or-new-php/#findComment-1153886 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.