jsk1gcc Posted January 10, 2011 Share Posted January 10, 2011 I have two drop down boxes that give me the result $extract and $extract2. The user can not pick the same seat in each drop down box. I am having a problem getting my IF statement to work, well it is working but not as I would like. When the page loads both boxes are null and are therefore the the same and the 'else' statement is shown. Is there a way to say...IF button is NULL on the page load then ignore? //SUBMIT BUTTON echo "<br>"; echo "<br>"; echo "<input type='submit' name='select' value='Select Seats'>"; echo "</form>"; //IF TO SEE IF TWO SEATS ARE SAME if ($_POST['select']="") { echo "please choose seats"; } if ($_SESSION['extract']==$_SESSION['extract2']) { echo "You have choosen the same seat twice, please choose two different seats. <a href='confirm.php'> Go Back</a>"; } Thanks. =) Link to comment https://forums.phpfreaks.com/topic/223921-if-statements-buttons-and-null/ Share on other sites More sharing options...
Zurev Posted January 10, 2011 Share Posted January 10, 2011 I have two drop down boxes that give me the result $extract and $extract2. The user can not pick the same seat in each drop down box. I am having a problem getting my IF statement to work, well it is working but not as I would like. When the page loads both boxes are null and are therefore the the same and the 'else' statement is shown. Is there a way to say...IF button is NULL on the page load then ignore? //SUBMIT BUTTON echo "<br>"; echo "<br>"; echo "<input type='submit' name='select' value='Select Seats'>"; echo "</form>"; //IF TO SEE IF TWO SEATS ARE SAME if ($_POST['select']="") { echo "please choose seats"; } if ($_SESSION['extract']==$_SESSION['extract2']) { echo "You have choosen the same seat twice, please choose two different seats. <a href='confirm.php'> Go Back</a>"; } Thanks. =) First change: if ($_POST['select']="") to a double == sign. http://php.net/manual/en/language.operators.comparison.php You're assigning $_POST['select'] to nothing everytime the if statement runs. Post the updated code with the errors afterwards. Link to comment https://forums.phpfreaks.com/topic/223921-if-statements-buttons-and-null/#findComment-1157239 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.