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

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.