title: md5 password retrieving
body: <p>i made a registration form and an login form. </p>
  
  <p>i used first used <code>trim()</code> and then <code>md5()</code> to store the password in database. </p>
  
  <p>i used the same to check the password in database in the login form, but for some unknown reason i cant match the md5 password from the login form. </p>
  
  <p>All i want is to retrieve the password from the database. </p>
  
  <p>The problem is when i store it in database and check it in the php myadmin the md5 password is something like <code>123456789</code> and when i echo'd it in login form it gives me this <code>1234567890</code>. a zero in the end tht zero is creating the problem otherwise the whole md5 password is matched. my database collation is <code>latin_1_swedish_ci</code>.</p>
  
  <p>is there any collation problem ? </p>
  
  <p>i hv used varchar value 255 then text etc. but no solution.  </p>
  
  <p>is there any problem in the format or structure ?</p>
  
  <p>please help me retrieve the md5 password correctly eliminating the unwanted zero .</p>
  
  <pre><code>function login()
  
      {
          if(isset($_POST['login']))
          {
              if(!$_POST['username'] || !$_POST['password'])
                  {die (mysql_error());}
  
              else
              {
                  $username = trim($_POST['username']);
                  $username = addslashes($_POST['username']);
  
                  $password = trim($_POST['password']);
                  $password = md5($_POST['password']);
                  echo $password;
  
  
                  $check_username = mysql_query("SELECT * FROM users WHERE username = '".$username."'")or die(mysql_error());
                  $check_username2 = mysql_num_rows($check_username);
  
                  if ($check_username2 == 0)
                      {die ("Username and password doesnt exist");}
                  else 
                      {
                          $check_pass = mysql_query("SELECT * FROM users WHERE username = '".$password."'")or die(mysql_error());
                          $check_pass2 = mysql_num_rows($check_pass); 
                          echo $check_pass2;
                      }
  
  
              }
          }
      }
  </code></pre>
  
  <p>and</p>
  
  <pre><code>function register()
  
      {
          if(isset($_POST['submit']))
          {
              if(!$_POST['first_name'] || !$_POST['last_name'] || !$_POST['username'] || !$_POST['password'])
                  {header ("Location:user_registration.php");}
  
              else
                  {
                      $firstname = trim($_POST['first_name']);
                      $firstname = addslashes($_POST['first_name']);
                      $lastname = trim($_POST['last_name']);
                      $lastname = addslashes($_POST['last_name']);
                      $username = trim($_POST['username']);
                      $username = addslashes($_POST['username']);
                      $password = trim($_POST['password']);
                      $password = md5($_POST['password']);
  
                      connect();
  
                      if($mysql_check_user = mysql_query("SELECT * FROM  `users` WHERE  `username` LIKE  '$username' "))
                          {
                              $check_row = mysql_num_rows($mysql_check_user);
                              if($check_row &gt; 0)
                              die ("username Exist");
                              else 
                                  {
                                      $store = mysql_query
                                              ("INSERT INTO `project_upload`.`users` 
                                              (`id`, `fname`, `lname`, `username`, `password`) 
                                       VALUES (NULL, '$firstname', '$lastname', '$username', '$password')");
  
                                  }
                              if ($store)
                                  {echo "You have regstered succesfully. please go to &lt;a href = 'uploads_login.php'&gt;login page&lt;/a&gt;";                                          }   
                              else {echo mysql_error();}
  
                          }
                  }
          }
      }
  </code></pre>