Thank you.
Here is the entire code
html>
<head>
<title>Lab 6 Registration Form Processing</title>
</head>
</body>
<?php
@require_once('lab6.php');
while(list($key,$val) = each($_POST)) {
$$key = $val;
$key = trim($key);
$key = stripslashes($key);
$key = strip_tags($key);
}
$errors = array();
if(empty($lname)){
$errors[] = <font color="red"> 'You did not enter your last name';
}elseif(preg_match("Last Name" >20,$lname)){
$errors[] = <font color="red"> $lname.' has too many characters';
}
if(empty($fname)){
$errors[] = <font color="red"> 'You did not enter your first name';
}elseif(preg_match("First Name" >20,$fname)){
$errors[] = <font color="red"> $fname.' has too many characters';
}
if(empty($address)){
$errors[] = <font color="red">'You did not enter your address';
}elseif(preg_match("Address" >30,$address)){
$errors[] = <font color="red"> $address.' has too many characters';
}
if(empty($city)){
$errors[] = <font color="red">'You did not enter your city';
}elseif(preg_match("City" >30,$city)){
$errors[] = <font color="red"> $city.' has too many characters';
}
if(empty($zip)){
$errors[] = <font color="red">'You did not enter your zip';
}elseif(preg_match("Zip Code" >5,$zip)){
$errors[] = <font color="red"> $zip.' has too many numbers';
}
if(empty($state)){
$errors[] = <font color="red">'You did not enter your state';
}elseif(preg_match("State" >2,$state)){
$errors[] = <font color="red"> $state.' has too many characters';
}
if(empty($phone1)){
$errors[] = <font color="red">'You did not enter your area code';
}elseif(preg_match("Phone" >3,$phone1)){
$errors[] = <font color="red"> $phone1.' has too many numbers';
}
if(empty($phone2)){
$errors[] = <font color="red">'You did not enter your phone number';
}elseif(preg_match("Phone" >3,$phone2)){
$errors[] = <font color="red"> $phone2.' has too many numbers';
}
if(empty($phone3)){
$errors[] = <font color="red">'You did not enter your phone number';
}elseif(preg_match("Phone" >4,$phone3)){
$errors[] = <font color="red"> $phone3.' has too many numbers';
}
if(empty($email)){
$errors[] = <font color="red">'You did not enter an email address';
}elseif(preg_match("Email" >20,$email)){
$errors[] = <font color="red"> $email.' has too many characters';
}elseif(!eregi("[a-z0-9_]+@[a-z0-9-]+.[a-z0-9-.]+$", $email)){
$errors[] = <font color="red"> $email.' is not in the proper format';
}
$nerrors = count($errors);
if($nerrors > 0) {
echo "\n".'<p>'.$nerrors.' problem(s) found</p>';
echo "\n".'<ol>';
for ($i = 0; $i < $nerrors; $i++)
echo "\n".'<li>'.$errors[$i].'</li>';
echo "\n".'</ol>';
// re-display the form in this area
@require_once('lab6.php');
exit;
}
<h1>Lab 6 PHP Form Validation</h1>
<hr>
?>
<form action='lab6.php' method='post'>
//print statements in the form to display information
<table>
<tr><td>Last Name:</td><td><input type='text' name='lname' size='20'/></td></tr>
<td> <?php print ("$lname"); ?> </td>
<tr><td>First Name:</td><td><input type='text' name='fname' size='20'/></td></tr>
<td> <?php print ("$fname"); ?> </td>
<tr><td>Address:</td><td><input type='text' name='address' size='30'/></td></tr>
<td> <?php print ("$address"); ?> </td>
<tr><td>City:</td><td><input type='text' name='city' size='30'/></td></tr>
<td> <?php print ("$city"); ?> </td>
<tr><td>Zip Code:</td><td><input type='text' name='zip' size='5'/></td></tr>
<td> <?php print ("$zip"); ?> </td>
<tr><td>State:</td><td><input type='text' name='state' size='2'/></td></tr>
<td> <?php print ("$state"); ?> </td>
<tr><td>Phone:</td><td>(<input type='text' name='phone1' size='3'/>)
<input type='text' name='phone2' size='3'/>
<input type='text' name='phone3' size='4'/></td></tr>
<td> <?php print ("$phone1"); ?> </td>
<td> <?php print ("$phone2"); ?> </td>
<td> <?php print ("$phone3"); ?> </td>
<tr><td>Email:</td><td><input type='text' name='email' size='20'/></td></tr>
<td> <?php print ("$email"); ?> </td>
</table>
<br>
<input type='submit' value='Submit' />
<input type='reset' value='Reset' />
<hr>
</form>
</body>
</html>