php用于密码验证

I posted part of the below code to another question for a problem I had,and found the solution.I can register,login and logout from my android device,which is good. However,now I am getting something strange. I added an extra functionality,so as to validate that both $user_pass and $confirm password variables are equal(comparing strings). However I always get a json message "Passwords don't match" from this.

if($userPass!==$confirmPass){


        $don = array('result' =>"fail","message"=>"Passwords don't match");

 }

The whole code is the following.

 <?php
  session_start();
  require "init.php";
  header('Content-type: application/json');

  $email = $_POST['email'];
  $user_name = $_POST['user_name'];

  $user_pass = $_POST['user_pass'];
  $passwordEncrypted = sha1($user_pass);  

  $confirmPass = $_POST['confirm_pass'];
  $confPasswordEncrypted = sha1($confirmPass);  

  $msg = "Congratulations. You are now registered to the most amazing app ever!";            

        if(!filter_var($email, FILTER_VALIDATE_EMAIL)){


            $don = array('result' =>"fail","message"=>"Please enter a valid email");

        }




        if($email && $user_name && $user_pass && $confirmPass && filter_var($email, FILTER_VALIDATE_EMAIL)){


        $sql_query = "select * from user_info WHERE email ='".mysqli_real_escape_string($con, $email)."' or user_name 
        ='".mysqli_real_escape_string($con, $user_name)."'";

        $result = mysqli_query($con, $sql_query);   

        $results = mysqli_num_rows($result);

        if ($results){
            $don = array('result' =>"fail","message"=>"Email or username exists.");
        }else{

            $sql_query = "insert into user_info values('$email','$user_name','$passwordEncrypted','$confPasswordEncrypted');";

            if(mysqli_query($con,$sql_query)){

                $don = array('result' =>"success","message"=>"Successfully registered!Well done");
                //mail($email,"Well done",$msg);
                $_SESSION['email']=$row['email'];
            }
        }
    } if(!$email){


        $don = array('result' =>"fail","message"=>"Please enter your email");                  


    }else if(!$user_name){


        $don = array('result' =>"fail","message"=>"Please enter your username");


    }else if(!$user_pass){


        $don = array('result' =>"fail","message"=>"Please enter a password");

     //The last if statement causes the problem.
    }else if($userPass!==$confirmPass){


        $don = array('result' =>"fail","message"=>"Passwords don't match");

    }


      echo json_encode($don);

?>

Try using

if(!strcmp($userPass,$confirmPass))

instead of

if($userPass!==$confirmPass)

Use strcmp method as desxribed in the link http://php.net/manual/en/function.strcmp.php

Fixed it. I had an extra parenthensis in

if($userPass!==$confirmPass))

so I changed it to

if($userPass!==$confirmPass)

:)