NameSilo

Help with this (PHP)

SpaceshipSpaceship
SpaceshipSpaceship
Namecheap AuctionsNamecheap Auctions
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
DomainEasy: white label portfolios are live. Enable yours.

We're social

Escrow.com
Spaceship
Domain Recover
CryptoExchange.com

NamePros updates

Filters for activity feeds
Your news feed, Latest activity, and the activity tab on profiles now have filter buttons: All, Posts, Quick replies, and Other. Your...
AIVikings
Catchy
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back