2016-12-10 68 views
-5

我到PHP新手,嘗試寫驗證問題是我有在這行代碼麻煩我form.now代碼:多個preg_match查詢?

$fullname_pattern = "/[a-zA-Z]+/"; 
$fullname = $_POST['fullname']; 

$email = $_POST['email']; 
$email_pattern = "/^[a-zA-Z]+([a-zA-Z0-9]+)[email protected][a-zA-Z]{3,50}\.(com|net|org)/"; 

$password = $_POST['password']; 
$password_pattern = "/(.){6,12}/"; 


if(preg_match($fullname_pattern,$fullname)) && 
     (preg_match($email_pattern,$email)) && 
     (preg_match($password_pattern,$password)) 
     {    
      header("Location: home.php"); 
     } 
    else 
      header("Location: registration.php"); 

不知道該怎麼辦!

+0

而且麻煩的是? –

+1

檢查你的')'在哪裏,有一個問題。 –

+0

問題是一個解析錯誤 –

回答

0

if(preg_match($fullname_pattern,$fullname)) 刪除最後一個 「)」

並添加這裏(preg_match($password_pattern,$password)))

像這樣:

if(preg_match($fullname_pattern,$fullname) && preg_match($email_pattern,$email) && preg_match($password_pattern,$password) ) {

+0

它的工作原理!謝謝。 –