title: Error with user already exists or not in PHP
body: <p>I am facing problem in user checking from my database. I have checked the previous suggestions but that has not helped me...</p>
  
  <p>My code is:</p>
  
  <pre><code>&lt;?php include 'conn.php';
  if(isset($_POST['submit']))
  {
      $fname=$_POST['fname'];
      $lname=$_POST['lname'];
      $user=$_POST['uname'];
      $email=$_POST['email'];
      $depart=$_POST['department'];
      $id=$_POST['id'];
      $phone=$_POST['phone'];
      $pass=$_POST['pass'];
      $cpass=$_POST['cpass'];
      $address=$_POST['address'];
      $securepassword=hash('sha512', $cpass);
      $chk_email="select count(*) from signup where Email='" . $email ."'";
      $chk_user="select count(*) from signup where Username='" . $user . "'";
      $result_mail=mysql_query($chk_email);
      $result_user=mysql_query($chk_user);
      $query_mail=mysql_fetch_row($result_mail);
      $query_user=mysql_fetch_row($result_user);
      if($cpass!==$pass)
      {
          header("location:setting.php");
          echo $_SESSION['pass']="password not match";
          return false;
      }
  
      if($query_mail[0]&gt;0)
      {
          header("locatio:setting.php");
          echo $_SESSION['username']="Username Already Exist";
          return false;
      }
      if($query_user[0]&gt;0)
      {
          header("location:setting.php");
          echo $_SESSION['email']="Email Already Exists";
          return false;
      }
  
  else
  {
      $qry="INSERT INTO signup (First_Name,Last_Name,Username,Email,Department,Employe_Id,Phone,Password,Address) VALUES ('$fname','$lname','$user','$email','$depart','$id','$phone','$securepassword','$address')";
  
      if(mysql_query($qry))
      {
          echo "&lt;script&gt;window.open('success.php','_self')&lt;/script&gt;";
          header('location:index.php');
      }
  }
  }
  ?&gt;
  </code></pre>
  
  <p>Can anyone tell me what is the error in my code?</p>
  
  <p>The previous questions and answers have not helped me. I know it is simple as a question but an error is an error.</p>