Dynadot Aftermarket: discover domain gems worth investing in. Visit our aftermarket.

Help with this (PHP)

Namecheap AuctionsNamecheap Auctions
SpaceshipSpaceship
Spacemail by SpaceshipSpacemail by 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
Close
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
Close
Thank you, rep added!
 
0
Close
No problem :)
 
0
Close
CatchedCatched

We're social

Escrow.com
Spaceship
Domain Recover
CryptoExchange.com

NamePros updates

Switch between accounts
You can now stay logged in to more than one NamePros account in the same browser. Click your avatar, then "Accounts in this browser", to...
AIVikings
Catchy
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back