2016-10-06 4 views
0

電子メールが2回使用されると問題が発生します。彼はすでに電子メールが使用されていることをユーザーに通知するために印刷しません。私はそれが動作を停止パスワード確認フィールドを追加した後しかし、前に働いていた。私がしたいのは、「電子メールが無効であるか、すでに利用されている」という印刷物です。電子メールが再度登録されたとき。PHPパスワードの電子メールとパスワードの確認フォームのエラーメッセージの印刷

if ($count==0) { 
 
    if ($_POST["password"] == $_POST["confirm_password"]) { 
 
     $query = "INSERT INTO login(username,email,password) VALUES('$username','$email','$encrypt')"; 
 
     if ($dbConnect->query($query)) { 
 
     $alert = "<div class='alert alert-success'> 
 
      <span class='glyphicon glyphicon-info-sign'></span> &nbsp; Registered successfully! 
 
     </div>"; 
 
     }else { 
 
     $alert = "<div class='alert alert-danger'> 
 
      <span class='glyphicon glyphicon-info-sign'></span> &nbsp; Error try again or contact web master! 
 
     </div>"; 
 
     } 
 

 
    } else { 
 

 

 
     $alert = "<div class='alert alert-danger'> 
 
     <span class='glyphicon glyphicon-info-sign'></span> &nbsp; Email is invalid or already taken.</div>"; 
 

 
    } 
 

 
    }

+0

申し訳ありませんが、あなたの完全なスクリプトをここにダンプして「なぜこの作品がないのですか」と尋ねるのは良い質問ではありません。自分でデバッグを開始してください。これは_your_スクリプトです。発生した場合は、_specific_質問のみを支援することができます。 – arkascha

+0

私は 'if($ _POST [" password "] == $ _POST [" confirm_password "]){' – devpro

+1

の 'else'の 'if($ count == 0){'ブランチが間違ったレベルにあり、適切なインデントを使用するときに自分自身が表示されます。 – arkascha

答えて

2

あなたはif($count == 0)ブロック内のコードブロックが存在する電子メールを入れました。そこにはいけません。それはelseブロックにあるでしょう。以下のコードを使用してください。

if ($count==0) 
{ 
    if ($_POST["password"] == $_POST["confirm_password"]) 
    { 
     $query = "INSERT INTO login(username,email,password) VALUES('$username','$email','$encrypt')"; 

     if ($dbConnect->query($query)) 
     { 
     $alert = "<div class='alert alert-success'> 
      <span class='glyphicon glyphicon-info-sign'></span> &nbsp; Registered successfully! 
     </div>"; 
     } 
     else 
     { 
     $alert = "<div class='alert alert-danger'> 
      <span class='glyphicon glyphicon-info-sign'></span> &nbsp; Error try again or contact web master! 
     </div>"; 
     } 

    } 
} 
else 
{ 
    $alert = "<div class='alert alert-danger'> 
    <span class='glyphicon glyphicon-info-sign'></span> &nbsp; Email is invalid or already taken.</div>"; 

} 
+0

アシスタントありがとう! – user6860260

+0

はい、そうです。 – devpro

関連する問題