Jump to content

PHP Validate Drop Down Menu


sloter

Recommended Posts

In PHP how would I go about getting it to check to see if a use has selected an option from a drop down menu.Sample:

<?php$select = htmlspecialchars($_POST['select']);if(!select == '') {echo 'Make a Selection';}else {echo 'Thank you for making a selection';}?><form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"><select name="select"><option value='' selected>Select one...</option><option value='' selected>Option 1</option><option value='' selected>Option 2</option><option value='' selected>Option 3</option></select></form>

Link to comment
Share on other sites

Don't you have to give each option a value? And removing the exclamation mark from before 'select' .... try it

<?php$select = htmlspecialchars($_POST['select']);if(select == '') {echo 'Make a Selection';}else {echo 'Thank you for making a selection';}?><form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"><select name="select"><option value='' selected>Select one...</option><option value='one' selected>Option 1</option><option value='two' selected>Option 2</option><option value='three' selected>Option 3</option></select></form>

Link to comment
Share on other sites

<?php$select = htmlspecialchars($_POST['select']);if($select == 'Select one...') {echo 'Make a Selection';}else {echo 'Thank you for making a selection';}?><form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"><select name="select"><option value='' selected>Select one...</option><option value='' selected>Option 1</option><option value='' selected>Option 2</option><option value='' selected>Option 3</option></select></form>

Link to comment
Share on other sites

<?php$select = htmlspecialchars($_POST['select']);if($select == 'Select one...') {echo 'Make a Selection';}else {... use php to handle selected value here ...echo 'Thank you for making a selection';}?><form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"><select name="select"><option value='' selected>Select one...</option><option value='1' selected>Option 1</option><option value='2' selected>Option 2</option><option value='3' selected>Option 3</option></select></form>

Link to comment
Share on other sites

You're exactly right. I live for my post count. I measure my life's worth by the number of posts I have here. In no way did I say that because I think you're being a jackass. It is purely based on post count. Good call! Welcome to the forum, please stay a while and let us know if there is anything at all that we can drop everything to help you with! In fact, the next time you have a question, just go ahead and send private messages to everyone. Also, please make sure you post the same question to every forum here. We love these things as much as people bumping their topics after 2 hours. Now excuse me while I go send you a request to be your friend. In addition to my post count, the second metric I use to measure my life's worth is how many online friends I have.

Link to comment
Share on other sites

You're exactly right. I live for my post count. I measure my life's worth by the number of posts I have here. In no way did I say that because I think you're being a jackass. It is purely based on post count. Good call! Welcome to the forum, please stay a while and let us know if there is anything at all that we can drop everything to help you with! In fact, the next time you have a question, just go ahead and send private messages to everyone. Also, please make sure you post the same question to every forum here. We love these things as much as people bumping their topics after 2 hours. Now excuse me while I go send you a request to be your friend. In addition to my post count, the second metric I use to measure my life's worth is how many online friends I have.
What online friends? Oh and yes and thanks for the offer for help! =)
Link to comment
Share on other sites

What online friends?
Well, in IPB you can add other users as your "friend", and then if they are online (i.e. active in the last 15 minutes), you have an online friend :)
Link to comment
Share on other sites

Archived

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

×
×
  • Create New...