title: PHP & MySQL compare password
body: <p>How does one check to see if a user has typed in the right password to log in?</p>
  
  <p>This is what (out of a bunch of combinations...) I am doing:</p>
  
  <pre><code>&lt;?
  
  $login = $_POST['login'];
  $password = $_POST['password'];
  
  mysql_connect('localhost', 'root', 'abc123');
  
  mysql_select_db('aun_vox') or die(mysql_error());
  
  $q = mysql_query("SELECT password FROM customer WHERE login='$login'");
  $db_pass = mysql_result($q, 0);
  
  if(md5($password) == $db_pass)
  {
      echo "You did it.";
  }
  
  else echo "Wrong.";
  
  ?&gt;
  </code></pre>
  
  <p>As I can see from the ouput, there's something wrong in the <code>mysql_result</code> bit, but I can't figure out the right way.</p>
  
  <p>Can someone please help.</p>