title: Generate Password PHP, MySQL
body: <p>Im trying to create a PHP page to generate a password and update a record with the new password on the database. There are two tables on the database I have to check the user exists on and I am not sure of the MySQL required to update the fields. Here is what I have so far:</p>
  
  <pre><code>if (isset($_POST['rest'])) {
  
          if (empty($_POST['email'])) { 
          echo "&lt;h2 class='output'&gt;You did not enter an email address&lt;/h2&gt;"; 
          } 
          else{ 
          $email = $_POST['email'];   
  
          mysql_select_db($database_localhost,$localhost) or die ("Couldn't select the database."); 
  
          $result1=mysql_query("SELECT * FROM student WHERE email='$email'"); 
          $result2=mysql_query("SELECT * FROM admin WHERE email='$email'");
  
          $rowCheck1 = mysql_num_rows($result1);
          $rowCheck2 = mysql_num_rows($result2); 
          if(($rowCheck1 &gt; 0) || ($rowCheck2 &gt; 0)){ 
  
          $newPass = md5( random_gen(8));
          mysql_query("INSERT INTO admin, student (password) VALUES (".$newPass.") WHERE email="$email"");
  
  }}
  </code></pre>
  
  <p>Any help would be greatly appreciated
  Thanks </p>