title: Can't login to my script in PHP
body: <p>I am trying to make myself a simple PHP website with a member login system. I have created the registration part of the website and entries successfully update/add to my Mysql database. However I just cannot get my login.php to login using the details. My php code for login.php is as follows;</p>
  
  <pre><code>&lt;?php
  if ($_POST['mem_email']) {
  //Connect to the database through our include 
  include_once "storescripts/connect_to_mysql.php";
  $email = stripslashes($_POST['mem_email']);
  $email = strip_tags($email);
  $email = mysql_real_escape_string($email);
  $password = ereg_replace("[^A-Za-z0-9]", "", $_POST['mem_password']); // filter everything     but numbers and letters
  $password = md5($password);
  // Make query and then register all database data that -
  // cannot be changed by member into SESSION variables.
  // Data that you want member to be able to change -
  // should never be set into a SESSION variable.
  $sql = mysql_query("SELECT * FROM members WHERE mem_email='$email' AND         mem_password='$password' AND mem_emailactivated='1'"); 
  $login_check = mysql_num_rows($sql);
  if($login_check &gt; 0){ 
  while($row = mysql_fetch_array($sql)){ 
      // Get member ID into a session variable
      $id = $row["mem_id"];   
      session_register('mem_id'); 
      $_SESSION['mem_id'] = $id;
      // Get member username into a session variable
      $username = $row["mem_username"];   
      session_register('mem_username'); 
      $_SESSION['mem_username'] = $username;
      // Update last_log_date field for this member now
      mysql_query("UPDATE members SET mem_lastlogin=now() WHERE mem_id='$id'"); 
      // Print success message here if all went well then exit the script
      header("location: member_profile.php?id=".$id); 
      exit();
  } // close while
  } else {
  // Print login failure message to the user and link them back to your login page
  print '&lt;br /&gt;&lt;br /&gt;&lt;font color="#FF0000"&gt;No match in our records, try again &lt;/font&gt;&lt;br /&gt;
  &lt;br /&gt;&lt;a href="login.php"&gt;Click here&lt;/a&gt; to go back to the login page.';
  exit();
  }
  }// close if post
  ?&gt;
  </code></pre>
  
  <p>And form which is located on the same page is as follows;</p>
  
  <pre><code>&lt;table align="center" cellpadding="5"&gt;
  &lt;form action="login.php" method="post" enctype="multipart/form-data" name="logform"  id="logform" onsubmit="return validate_form ( );"&gt;
  &lt;tr&gt;
  &lt;td class="style7"&gt;&lt;div align="right"&gt;Email Address:&lt;/div&gt;&lt;/td&gt;
        &lt;td&gt;&lt;input name="mem_email" type="text" id="mem_email" size="30" maxlength="64" /&gt;&lt;/td&gt;
      &lt;/tr&gt;  
      &lt;tr&gt;
        &lt;td class="style7"&gt;&lt;div align="right"&gt;Password:&lt;/div&gt;&lt;/td&gt;
        &lt;td&gt;&lt;input name="mem_password" type="password" id="mem_password" size="30" maxlength="24" /&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;&amp;nbsp;&lt;/td&gt;
        &lt;td&gt;&lt;input name="Submit" type="submit" value="Login" /&gt;&lt;/td&gt;
      &lt;/tr&gt;
    &lt;/form&gt;
  &lt;/table&gt;
  </code></pre>
  
  <p>My database looks like this</p>
  
  <pre><code>mem_id  int(11)
  mem_username    varchar(255)
  mem_country varchar(255)
  mem_county  varchar(255)
  mem_address varchar(255)
  mem_email   varchar(255)
  mem_password    varchar(255)
  mem_signupdate  datetime
  mem_lastlogin   datetime
  mem_accounttype enum('a', 'b', 'c')
  mem_emailactivated  enum('0', '1')
  mem_postcode    varchar(255)
  mem_city    varchar(255)
  </code></pre>
  
  <p>Every time the correct data is entered into my login form, I am processed to the else statement with the failure message</p>