PHPBuilder - Email Validity



RSS Twitter
Snippets Http

Email Validity

by: Sanjeev Ram Vaidya
|
May 22, 2001

Version: 1

Type: Full Script

Category: HTTP

License: Other

Description: Check if the entered email address is valid or not.



<?
function disp_header()
{
global $PHP_SELF;
?>
<form method=post action=<?echo$PHP_SELF?>>
<input type=hidden name=sub value="ok">
Enter Email address <br>
<input type=text name=EMAIL size="20" value=<?echo$EMAIL?>>
&nbsp;
<input type=submit name=submit value=Check>
</form>
<?
}

if (empty($sub))
{
	disp_header();
}
elseif ($sub == "ok")
{
	$CHECK= strstr ($EMAIL, '@');
	$CHECK1= strstr ($CHECK, '.');
list( $name, $host) = split( '[@]', $EMAIL );  
list( $host1, $host2, $host3) = split( '[.]', $host);
if ( ( ereg( "([~!#$%^&*])", $EMAIL)) || (!$CHECK) || ($CHECK == "@") ||
(!$CHECK1) || ( ereg( "([@])", $name)) || ($host1== "")	 )
	{
	print "$EMAIL not valid Email Address\n"."<br>\n";
	}
	else
	{
		if ($name == "")
		{
		print "Entered email address <$EMAIL> is wrong\n";
		}
		else
		{
		Print "valid email address $EMAIL";
		}
	}           
}
?>

Comment and Contribute

Your comment has been submitted and is pending approval.

Author:
Sanjeev Ram Vaidya

Comment:



Comment:

(Maximum characters: 1200). You have characters left.