2013-03-26 197 views
-1

你好,我想检查电子邮件是否有效,如[email protected],而不是像纯文本'BLbalbalba'。使用Pregmatch错误检查电子邮件是否有效?

我有这样的功能:

function VerifyEmail($address) 
{ 
    $Syntax='#^[w.-][email protected][w.-]+.[a-zA-Z]{2,5}$#'; 
    if(preg_match($Syntaxe,$adrdess)) 
     return true; 
    else 
    return false; 
} 

并检查它是这样的:

$email = htmlentities($_POST['email']); 
if (!empty($email) && !empty($password) && !empty($message) && VerifyEmail($email) === true) { 

收到这些错误:

Notice: Undefined variable: Syntaxe in C:\xampp\htdocs\recover\inc\functions.inc.php on line 20 

Notice: Undefined variable: adrdess in C:\xampp\htdocs\recover\inc\functions.inc.php on line 20 

Warning: preg_match() [function.preg-match]: Empty regular expression in C:\xampp\htdocs\recover\inc\functions.inc.php on line 20 

Notice: Undefined variable: Syntaxe in C:\xampp\htdocs\recover\inc\functions.inc.php on line 20 

Notice: Undefined variable: adrdess in C:\xampp\htdocs\recover\inc\functions.inc.php on line 20 

Warning: preg_match() [function.preg-match]: Empty regular expression in C:\xampp\htdocs\recover\inc\functions.inc.php on line 20 

这究竟是为什么?我做错了什么?检查电子邮件是否有效是否是一种稳定的方式? 谢谢!

+0

'$ Syntax!= $ Syntaxe' – 2013-03-26 05:07:14

+0

接受已解决您问题的答案... :) – 2013-03-26 05:48:15

回答

3

这里

一些拼写错误,应该是

function VerifyEmail($address) 
{ 
    $Syntax='#^[w.-][email protected][w.-]+.[a-zA-Z]{2,5}$#'; 
    if(preg_match($Syntax,$address)) 
相关问题