ユーザーを更新するためにプログラムにセクションを書いていますが、パスワードとパスワードの確認があります。フィールドに入力していない限り、DBのパスワードフィールドには何もしたくありません。
したがって、次のエラーチェックがあります。
if(($sql['password']!="") && ($sql['cpassword']!=""))
{
if($sql['password'] == $sql['cpassword'])
{
//update
}
}
ただし、パスワード フィールドの 1 つだけを入力した場合にエラー メッセージをスローする簡単な行を書きたいと思います。だから私は考え出した:
if($sql['password'] ^ $sql['cpassword'])
{
echo You must fill out <i>both</i> password fields and they <i>must</i> match.";
}
やりますが、そうではないようです。次に、NOT 演算子 ! を追加しましたが、うまくいくように見えましたが、両方のフィールドに何もない場合でも、エラー メッセージが表示されます :(
この回答からわかるロジックから、単純な XOR が機能するように思われます。しかし、そうではありません。誰かが私に理由を説明できますか?