Jump to content

email validation help using expression


jmantra

Recommended Posts

Hi all,

 

I am trying to use an expression to validate an e-mail address, but if i enter a proper email addy (ie [email protected]) it tells me invalid email:

 


<?php
// check e-mail address
// display success or failure message
if (!preg_match("/^([a-zA-Z0-9])+@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-]+)+/", $_POST['email']))
{
die("Invalid e-mail address");
}
echo "Valid e-mail address, processing...";
$file = fopen("/var/lists/flagstore/flagadd","a+");
fwrite($file, $_POST["name"] . ' '); 
fclose($file);

?>

 

 

any help would be greatly appreciated. Thanks :)

Link to comment
https://forums.phpfreaks.com/topic/61728-email-validation-help-using-expression/
Share on other sites

Don't ask questions.

"/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*(([,]|[, ])\s*\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*)*$/"

 

 

Hmm...I'm going to have to try that one Charlie...

 

 

This one is fairly simple, actually readable...and hasn't screwed up on me yet...

 

'/^[a-z0-9.-_]+@[a-z0-9.-_]+\.[a-z]{2,4}$/'

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.