Estoy tratando de validar mi formulario
Quiero que valide mi email y tambien la edad .
que imprima cuando la edad sea un numero "integer"
Mi codigo es como sigue ... a ver si alguien me ayuda recien estoy aprendiendo...
<html>
<head>
Form
</head>
<body>
<?
//Create a function to display a form when called:
function display_form()
{
//Make form variables global
global $fname;
global $lname;
global $email;
global $age;
$myform=<<<EndForm
<form action=validating3.php4 method="post">
Enter First Name: <input type=text name="fname" size=15 value="$fname"><br>
Enter Last Name: <input type="text" name="lname" size=15 value="$lname"><br>
Enter E-mail Adress: <input type="text" name="email" size=15 value="$email"><br>
Enter your age: <input type="text" name="age" size=3 value="$age"><br>
<input type=submit value="Submit Information" name="submit">
</form>
</body>
</html>
EndForm;
return $myform;
}
//test if first time script being called
if(!$submit)
{
print(display_form($myform));
exit();
}
//Test to see if user entered the mandatory information
if((!$fname) || (!$lname) || (!$email) || (!$age))
{
$message=<<<EndMessage
<h2 align=center><font color=green>Your registration was missing the following
information:</font></h2>
EndMessage;
//Display error message
print($message);
//Display list of missing data
if(!$fname)
{
print("<b>Your First Name</b><br>");
}
if(!$lname)
{
print("<b>Your Last Name</b><br>");
}
if (!$email)
{
print("<b>Your Email</b><br>");
}
if(!$age)
{
print("<b>Your Age</b><br>");
}
print("<b>Please make the necessary corrections:</b>");
print("</font></center>" . display_form($myform));
}
// EMAIL
if ($email)
{
//Display if email address has a minimum of characters
if ((strlen($email) >= 1) && (strlen($email) < 7))
{
print("Your e-mail address was only ".strlen($email)." character(s) long <br>");
}
// Display if email does not has an 'at' symbol
if (!strpos($email, "@"))
{
print("Your e-mail address was missing the \"@\" symbol<br>");
}
// Display if email does not has an '.' symbol
if (!strpos($email, "."))
{
print("Your e-mail address was missing the dot \".\" symbol<br>");
}
//Conclude the error message by redisplaying form with original values
print("<b>Please make the necessary corrections:</b>");
print("</font></center>" . display_form($myform));
exit();
}
//If all information was provided give thank you message
else
{
$message=<<<EndMessage
<p align=center>Thank you<br>You inserted the following information:<br>
Name: $fname $lname<br>
Email: $email<br>
Age: $age</p>
EndMessage;
print($message);
}
?>
</body>
</html>