我试图创建一个 PHP 页面来生成密码并使用数据库上的新密码更新记录。数据库上有两个表我必须检查用户是否存在,我不确定更新字段所需的 MySQL。这是我到目前为止所拥有的:
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"");
}}
任何帮助将不胜感激谢谢