Jump to content

If statements, Buttons and NULL


jsk1gcc

Recommended Posts

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

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.  :)

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.