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:
if (isset($_POST['rest'])) {
if (empty($_POST['email'])) {
echo "<h2 class='output'>You did not enter an email address</h2>";
}
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 > 0) || ($rowCheck2 > 0)){
$newPass = md5( random_gen(8));
mysql_query("INSERT INTO admin, student (password) VALUES (".$newPass.") WHERE email="$email"");
}}
Any help would be greatly appreciated
Thanks
you should use the sql update statement. The insert statement will add a new row to the student and admin tables.
so your code should look something like:
}