title: Using MD5 on login page
body: <pre><code>&lt;?php
  
  include("connect.php");
  session_start();
  if ($_SERVER["REQUEST_METHOD"] == "POST") {
      // Username and password sent from form in HTML
      $myusername = $_POST['username'];
      $mypassword = $_POST['password'];
  
      $sql    = "SELECT id FROM users WHERE username='$myusername' and password='$mypassword'";
      $result = mysql_query($sql);
      $row    = mysql_fetch_array($result);
      $active = $row['active'];
      $count  = mysql_num_rows($result);
  
      // If result matched $myusername and $mypassword, table row must be 1 row
      if ($count == 1) {
          session_register("myusername");
          $_SESSION['login_user'] = $myusername;
  
          header("location: welcome.php");
      } else {
          $error = "Your username or password is invalid";
      }
  }
  
  ?&gt;
  </code></pre>
  
  <p>This is my current login code. On my registration page, I have it so that when it injects into the database, it injects the passwords already encrypted in MD5. However, I cannot seem to convert:</p>
  
  <pre><code>$mypassword=$_POST['password'];
  </code></pre>
  
  <p>Into MD5 to confirm to see if the password exists in the database. With this code, the passwords must not be encrypted. What should I change to make it so that it checks with the database <strong>encrypted</strong>?</p>