Dynadot โ€” .com Registration $8.99

Help with this (PHP)

Spaceship Spaceship
Watch
Impact
11
I working on a project, but i dont know how to fix the problem i have. The code below was with a script i got, but it doesnt work. Its suppose to check if the email has valid characters but it says it has invalid characters no matter what i type (ill do [email protected], testgmail.com, test@gmailcom, testgmailcom, and none will work)


PHP:
			if (!preg_match('/^[A-z0-9_\-]+\@(A-z0-9_-]+\.)+[A-z]{2,4}$/', $email)){
				$err = 1;
				$error_html .= "$LANG_err_email.<br><br>\n";
		}

Can anyone fix it? Thanks!
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
PHP:
if (!preg_match('/^[a-z0-9_\-]+\@(a-z0-9_-]+\.)+[a-z]{2,4}$/si', $email))
{
    $err = 1;
    $error_html .= "$LANG_err_email.<br><br>\n";
}

Should work. Or here's a function I'm using in one of my scripts
PHP:
function is_valid_email($email)
{
    $pattern = '/^[a-z0-9&\.\-_\+]+@[a-z0-9\-]+\.([a-z0-9\-]+\.)*?[a-z]{2,6}+$/is';
    
    return (preg_match($pattern, $email)) ? true : false;
}

// Use it like..
if (!is_valid_email($email))
{
    $err = 1;
    $error_html .= "$LANG_err_email.<br><br>\n";
}
 
1
•••
Thank you, rep added!
 
0
•••
No problem :)
 
0
•••
Unstoppable Domains
Domain Recover
DomainEasy โ€” Live Options
  • The sidebar remains visible by scrolling at a speed relative to the pageโ€™s height.
Back