title: After hashing the password using md5() and store it into database,cant login again
body: <p>i built a login and registration system before,is running well.After I hash the input password using md5()and store it to the database,it cant login anymore.So everyone pls look at my code here,so i can know what goes wrong..here is my code here.. </p>
  
  <p>signup.php </p>
  
  <pre><code>include ('config.php');
  
  $errors=array();   
  
  if ($_SERVER["REQUEST_METHOD"] == "POST"){
    $username=htmlentities($_POST['username']);
    $password=htmlentities($_POST['password']);
    $email=htmlentities($_POST['email']);
    $cpassword=htmlentities($_POST['cpassword']);
      //not empty
      //at least 3 characters long
      //username and password cannot be same
  
      //start the validation
  
      //check the username
      if(empty($_POST['username'])){
          $errors['username1'] = "Required fields";
      }
  
      else if (strlen($username)&lt;6 ) {
          $errors['username2'] = "Username should at least 6 characters long";
      }
  
      else if (!preg_match('/^[a-z\d_]{3,20}$/i', $username)) {
          $errors['username3'] = "Username should contain letters and numbers only.";
      }
  
      //check the password
      if (empty($_POST['password'])){
          $errors['password1'] ="Required fields";
      }
      else if (strlen($password) &lt;8) {
          $errors['password2'] ="Password should at least 8 characters long";
      }
  
      else if(!preg_match('/^(?=.*\d)(?=.*[A-Za-z])[0-9A-Za-z!@#$%]{8,20}$/', $password)){
          $errors['password3'] ="Password should contain at least 1 upper-case,1 lower-case,numbers ";
      }
  
      //check the password confirmation
      if(empty($cpassword)) {
          $errors["cpassword2"] = "Must confirm your password to proceed";
      }
  
      if($password != $cpassword){
          $errors['cpassword1']="Password do not match";
      }
  
      //check whether username or password is same
      if($username == $password){
          $errors['sameuserpass'] ="Username and password cannot be same";
      }
  
  
      //check the email
      if (empty($_POST['email'])){
          $errors['email1'] = "Required fields";
      }
  
      else if(!filter_var($email, FILTER_VALIDATE_EMAIL)){
          $errors['email3'] ="Please enter a vaild email address";
      }
  
      //check the errors
      if(count($errors) == 0){
  
      $query=mysqli_query($con,"SELECT * FROM user WHERE Username='$username'");
      $query1=mysqli_query($con,"SELECT*FROM user WHERE Email='$email'");
         if(mysqli_num_rows($query) &gt; 0) {
             $errors['userexist'] ="Username already exists";
         } 
  
         else if(mysqli_num_rows($query1) &gt; 0){
             $errors['emailexist'] = "Email already already exists";
         }
  
         else {
              //HASHING THE PASSWORD
             $password = md5($password);
  
              $queryinsert= "INSERT INTO user(Username,Password,Email) VALUES ('$username','$password','$email')";
              mysqli_query($con,$queryinsert);
  
              header("Location:login.php");
         }
  
      }
  }
  </code></pre>
  
  <p>login.php</p>
  
  <pre><code>&lt;?php
  include('config.php');
  
      session_start();
  
      $errors=array();
  
   if ($_SERVER["REQUEST_METHOD"] == "POST"){
  
      $email = htmlentities($_POST['email']);
      $password = htmlentities(md5($_POST['password']));
  
      if($email&amp;&amp;$password){
  
          //declare variable
  
          $query = mysqli_query($con,"SELECT * FROM user WHERE Email='$email' ");
          $numrows = mysqli_num_rows($query);
  
          //when user correct input,check the data 
          if($numrows !== 0) {
              while($row=mysqli_fetch_assoc($query)){
                  $dbemail=$row['Email'];
                  $dbpassword=$row['Password'];
              }
  
  
              if($dbemail === $email&amp;&amp;$dbpassword === $password)
              {
                  $_SESSION['email']="$email";
                  header('Location:user.html');
                  exit;
              }
  
              else
              {
                  $errors['notcorrect'] = "Email or password not correct";
              }
          } 
          //when insert wrong data
          else{
              $errors['notexists'] = "This email doesn't exists";
          }
      }
      //when user didnt enter anything
      else{
          $errors['nothing'] = "Please enter your email and password";
      }
  }
  
  ?&gt;
  </code></pre>
  
  <p>I successfully store the password that hashed into the database,but the problem is cant login again although the email address and password is correct.Any idea?</p>