Hello Reader's today we will discuss about "Email validation in Php".
The below code tells that how to check your email is valid or not. For this we use regular expression for validate email.
<?php
if(isset($_POST['submit']))
{
$email_from = $_POST['email'];
$email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/';
if(preg_match($email_exp,$email_from)) {
echo 'The Email Address you entered does not appear to be valid.';
}
else
{
echo $error_message .= 'The Email Address you entered does not appear to be invalid.';
}
}
?>
<form method="post">
<div>
<input type="text" name="email" id="email" value="" />
</div>
<div>
<input type="submit" name="submit" id="submit" value="Submit" />
</div>
</form>
0 Comment(s)