title: Forgotpassword function not working, sql, php
body: <p>Not sure what happened but its suddenly stopped working...
  I can enter the email and username (i know the credentials are correct) and get the message that it wont find any matching details...</p>
  
  <p>The content of forgotpassword.php:</p>
  
  <pre><code>&lt;?php
  require_once("users.inc");
  
  $PAGE_TITLE = "Forgotten Password";
  
  include $PHP_USERS_HEADER_FILE; 
  
  ?&gt;
  
  &lt;h3&gt;Forgot Your Password?&lt;/h3&gt;
  
  &lt;p&gt;If you've forgotten your password, just enter the username and email address that you registered with, and your password will be emailed to you immediately.&lt;/p&gt;
  
  
  
  &lt;form method="post" action="emailpassword.php"&gt;
    &lt;p&gt;&lt;b&gt;Your Username: &lt;/b&gt;
    &lt;input type="text" name="username" size="35" /&gt;
    &lt;/p&gt;&lt;p&gt;
    &lt;b&gt;Your Email Address: &lt;/b&gt;
    &lt;input type="text" name="email" size="35" /&gt;
    &lt;/p&gt;
    &lt;input type=submit value="Submit" /&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>the content of emailpassword.php:</p>
  
  <pre><code>&lt;?php
  require_once("users.inc");
  
  $PAGE_TITLE = "Forgotten Password";
  
  connect_to_users_db();
  
  $password = fnRandomPassword(8);
  $encrypt_pwd = md5($password);
  
  $sql = "UPDATE users SET password='$encrypt_pwd' WHERE email='".$_REQUEST['email']."' AND username='".$_REQUEST['username']."'";
  $query = mysql_query($sql);
  
  $sql1 = "SELECT email, username, password FROM users WHERE email='".$_REQUEST['email']."' AND username='".$_REQUEST['username']."'";
  $query1 = mysql_query($sql1);
  if ($query1 &amp;&amp; (mysql_num_rows($query1) &gt; 0)) {
  
    while (list($email,$username) = mysql_fetch_row($query1)) {
      mail($email, "Your Password", "Below is the username and password information you requested.\n\nUsername: '$username'\nPassword: '$password'.\n\n","From: $WEB_MASTER &lt;$WEB_MASTER_EMAIL&gt;\n");
  
  }
  }
  
  
  include $PHP_USERS_HEADER_FILE; 
  
  ?&gt;
  
  &lt;h3&gt;Forgot Your Password?&lt;/h3&gt;
  
  &lt;?
  
  echo "&lt;p&gt;";
  
  //if ($query &amp;&amp; mysql_num_rows($query) &gt; 0) { 
  if (mysql_affected_rows() &gt; 0) { 
  
  ?&gt;
  
  &lt;p&gt;We've emailed your password. You should receive it within a minute. If you don't, please send mail to the &lt;a href="mailto:&lt;?=$WEB_MASTER_EMAIL?&gt;"&gt;&lt;?=$WEB_MASTER?&gt;&lt;/a&gt;.&lt;/p&gt;
  
  &lt;?php
  
  } else { 
  
  ?&gt;
  
  &lt;p&gt;We could not find an email and username corresponding with the email address and username you entered. Perhaps you registered with a different email address/username. Use the form below to try again.&lt;/p&gt;
  
  
  
  &lt;form method="post" action="emailpassword.php"&gt;
    &lt;p&gt;&lt;b&gt;Your Username: &lt;/b&gt;
    &lt;input type="text" name="username" size="35" /&gt;
    &lt;/p&gt;&lt;p&gt;
    &lt;b&gt;Your Email Address:&lt;/b&gt;
    &lt;input type="text" name="email" size="35" /&gt;
    &lt;/p&gt;
    &lt;input type="submit" value="Submit" /&gt;
  &lt;/form&gt;
  
  
  &lt;p&gt;If you believe you have not registered before, you are welcome to sign up now with the following form:&lt;/br&gt;
        &lt;?php include 'fragments/requestaccont.htm';?&gt;
  
  &lt;?php
  
  }
  
  ?&gt;
  </code></pre>
  
  <p>Is there some outdated coding here or something?</p>