adicrst Posted November 20, 2008 Share Posted November 20, 2008 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 More sharing options...
DarkerAngel Posted November 20, 2008 Share Posted November 20, 2008 function checkemail($email) { if(preg_match('#[a-zA-Z0-9][a-zA-Z0-9\.\-\_]*@[a-zA-Z0-9\-\_]*\.[a-zA-Z0-9\_\.\-]*[a-zA-Z0-9]#', $email)) return true; else diefalse; } Link to comment https://forums.phpfreaks.com/topic/133426-email-validator/#findComment-693981 Share on other sites More sharing options...
adicrst Posted November 20, 2008 Author Share Posted November 20, 2008 works, thanks. Could you clarify for me why my function didn't worked ? Link to comment https://forums.phpfreaks.com/topic/133426-email-validator/#findComment-693986 Share on other sites More sharing options...
DarkerAngel Posted November 20, 2008 Share Posted November 20, 2008 I'm not sure, I think it has something to do with the predefined function and I don't know how its coded. Link to comment https://forums.phpfreaks.com/topic/133426-email-validator/#findComment-693992 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.