#native_company# #native_desc#
#native_cta#

Checks for validations of Email

By James Smith
on May 23, 2001

Version: 2

Type: Full Script

Category: Other

License: GNU General Public License

Description: The Program checks for (@, . and spaces in between email) returns 1 if the email is valid else returns 0 if the email is invalid

<?	
// Code by James Smith
// Email [email protected]
function plugin($email)
{
		$pat1 = "@";	
		$emailarr = split ($pat1,$email);		
		$email1 = $emailarr[0];
		$email2 = $emailarr[1];			
		$email = trim($email);
		$elen = strlen($email);
		//find for dot	46 ord of . =================================	
		$dotpresent = 0;
		for ($i=2;$i<=$elen;$i++)
		{
			$j = substr($email,0,$i);
			$jlen = strlen($j);			
			$lastj = substr($j,$jlen-1,$jlen);			
			$asci = ord($lastj);				
			if ($asci==46)
			{				
				$dotpresent = 1;
			}						
		}	
		//find for space 32 ord of space in between ====================
		$spaceexist = 0;
		for ($k=0;$k<$elen;$k++)
		{
			$myword = substr($email,$k,1);			
			if (ord($myword)==32)
			{
				$spaceexist = 1;
			}
			
		}				
		if ($email2)
		{
			$atpresent = 1;
		}		
		if ($atpresent=='1' AND $dotpresent=='1' AND $spaceexist=='0')
		{
			$validmail = 1;
		}
		else
		{
			$validmail = 0;
		}		
		return ($validmail);		
}		

		$email = "[email protected]";
		$validmail = plugin($email);	
		//Return 1 if email is valid else 0 if mail is invalid
		print ("$email is $validmail");

		
?>