Sun Jun 14 2020
E-mail Validation
PHP Scripting1043 views
File Name: email-validation.php
<html>
<head>
<title>Email Validation</title>
</head>
<body>
<form method="POST" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<input type="email" autocomplete="off" required name="email" placeholder="Enter a email address" />
<input type="submit" value="Validate" />
</form>
<?php
if(isset($_POST['email'])) {
$email = $_POST['email'];
$valid = ereg("^[^@ ]+@[^@ ]+\.[^@ \.]+$", $email);
if ($valid)
echo "<br />It's a valid email address!";
else
echo "<br />It's a invalid email address!";
}
?>
</body>
</html>
/* Output */
E-mail: a@g
It's a invalid email address!
/* ------------------------------------------ */
E-mail: geek@geekboots.com
It's a valid email address!
Reference:
Author:Geekboots