How do you validate drop down menus?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
TheDumbNerd
Forum Newbie
Posts: 13
Joined: Sun Nov 13, 2011 4:01 pm

How do you validate drop down menus?

Post by TheDumbNerd »

<form name="Stumarks" action="report.php" method="GET">
School: <select name="school" value="<?php echo $school; ?>" /></input><font color="red"><?php echo $schoolerror; ?></font></p>
<option value="blank" >---Select a school---</option>
<option value="MT">MT</option>
<option value="LDH">LDH</option>
<option value="MHS">MHS</option>
</select>
<input type="Submit">
</form>


How would I validate the drop down menu so that if the user had not selected one of the options than, the they will get redirected to the originial document and an error message would pop up beside the form. I have two documents.
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: How do you validate drop down menus?

Post by Celauran »

Code: Select all

if ($_POST['school'] == 'blank')
Post Reply