Friday, 13 April 2018

WT-Slip25

25)Design a HTML form to accept email address from the user. Write a PHP function using regular expressions check for the validity of entered email-id. The @ symbol should not appear more than once. The dot (.) can appear at the most once before @ and at the most twice or at least once after @ symbol. The substring before @ should not begin with a digit or underscore or dot or @ or any other special character.                                                                              

<form action=''  method='POST'>

Email Address: <input type='text' name='email'>

<input type='submit' value='Submit'>

</form>

<?php

//$email = "someone@example.com";

$email=$_POST['email'];
//if(eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email))

if ( eregi('^[a-zA-Z0-9._-]+@[a-zA-Z0-9._-]+.([a-zA-Z]{2,4})$',$email))

{
echo "Valid email address.";
}
else
{
echo "INvalid email address.";
}

?>