3

i want to see if lazar@hotmail.com23 is valid (it isnt) in the PHP code here:

 // Remove all illegal characters from email
            $Buyer_Email = filter_var($Buyer_Email, FILTER_SANITIZE_EMAIL);

            // Validate e-mail
            if (filter_var($Buyer_Email, FILTER_VALIDATE_EMAIL) && preg_match('/@.+\./', $Buyer_Email) === false) {

but the code says its valid.

i checked online and i cant seem to figure out whats wrong

Whats wrong?

Gilles 'SO- stop being evil'
  • 104,111
  • 38
  • 209
  • 254
Lazar
  • 99
  • 8
  • 1
    Which part of your if statement is coming back true? The filter-var or the preg_match? – Matt Mar 06 '16 at 23:42
  • 1
    Technicaly, it is valid if checked by a regexp. If you want more comprehensive validation you could use DNS lookup of some sort. Something like this : https://davidwalsh.name/php-email-validator – Mathieu de Lorimier Mar 06 '16 at 23:43
  • 1
    i am assuming preg_match and this helps M de Lormier ill look into it! – Lazar Mar 06 '16 at 23:47
  • why both with the preg_match at all? just use the `filter_var` –  Mar 07 '16 at 00:01

0 Answers0