Hi Dave,
Here are a few samples I use on our forms. They are not perfect and I am sure they can be improved.
Emal Sample
if (! ereg('[A-Za-z0-9_-]+\@[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+', $EmailAddress))
{
die("<p align='center'><font face='Arial' size='3' color='#FF0000'>You did not enter a valid email address.<br>Please use the 'Back' button to correct this entry.</font></p>");
}
Ensure that at least 1 checkbox is selected in a group (for required check boxes)
if(!isset($_POST['GradeLevel'])) { // You did not select any boxes
$_POST['GradeLevel'] = array();// Make it an array
die("<p align='center'><font face='Arial' size='3' color='#FF0000'>You did not select a Grade Level Taught. <br>Please hit the back button and choose a Grade Taught.</font></p>"); // Go back
} else {
foreach ($_POST['GradeLevel'] as $grade) { //Set the elements in the array
$GradeLevel7 = $grade[0];
$GradeLevel8 = $grade[1];
$GradeLevel9 = $grade[2];
$GradeLevel10 = $grade[3];
$GradeLevel11 = $grade[4];
$GrageLevel12 = $grade[5];
}
}
Check last name lto make sure it is at least 2 characters long
if (strlen($LastName) <2)
{
die("<p align='center'><font face='Arial' size='3' color='#FF0000'>You did not enter your last name.<br>Please use the 'Back' button to correct this entry.</font></p>");
}
Hope this helps,
Don