hi i need to check an email address to see if it follows the basic layout, check that it has the @ and the . after the at is there somewere. any ideas?
$email = strtolower($email); if(preg_match('#^[-_a-z0-9]+(\.[-_a-z0-9]+)*@[-a-z0-9]+(\.[-a-z0-9]+)*\.[a-z]{2,6}$#',$email)) { echo "correct"; } else { echo "wrong"; }
I haven't tested this code!
Try this:
<?php $string = "user@domain.com"; if(preg_match("/^([a-zA-Z0-9_-.]+)@(([[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.)|(([a-zA-Z0-9-]+.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(]?)$/",$string)) { echo "It's a match."; } else { echo "Not a match"; } ?>