Jump to content

email validator


adicrst

Recommended Posts

i have this function that sanitizes the email, but for some reason it doesn't work for white spaces like 'test @test.com'. Why ?

 

$string = '[email protected]';
function spamcheck($mail)
 {
	  $mail = filter_var($mail, FILTER_SANITIZE_EMAIL);
	  if(filter_var($mail, FILTER_VALIDATE_EMAIL))
		{
			return TRUE;
		}
	  else
		{
			return FALSE;
		}
 }

if (spamcheck($string) != FALSE)
{
	$email = $sir;
	echo $email;
}
else
{
	echo '<br />Invalid email address!';
	$error = true;
}

Link to comment
https://forums.phpfreaks.com/topic/133426-email-validator/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.