我有一个忘记密码的php页面,如果他的电子邮件在数据库中,则会向用户发送密码。代码正在运行,但发送的电子邮件中的密码为空。我认为这是因为我没有把它转换为字符串,但我不知道该怎么做。我也在数据库中保存了密码,这会影响到什么吗?
盐:
<?php
$salt1 = "qm&h*";
$salt2 = "pg!@";
$token = hash('ripemd128', "$salt1$pass$salt2");
?>
忘记密码php页面:
<?php
$error = $email = "";
if (isset($_POST['email']))
{
$email = sanitizeString($_POST['email']);
if ($email == "")
$error = "Not all fields were entered<br>";
else if (!filter_var($email, FILTER_VALIDATE_EMAIL))
$error='Email is invalid';
else
{
$resultE = queryMySQL("SELECT email FROM users WHERE email='$email'");
$result_pass = queryMysql("SELECT * FROM users WHERE email='$email'");
$row = $result_pass->fetch_array(MYSQLI_ASSOC);
$user_pass = $row['[pass]'];
if ($resultE->num_rows == 0)
{
$error = "<span class='error'>Email
error</span><br><br>";
}else
{
$mail_to = $email;
$subject = 'This is your registered password ';
$body_message = 'Password: '."\n\n".$user_pass; //convert to string
$mail_status = mail($mail_to, $subject, $body_message);
if(isset($_SESSION['url']))
$url = $_SESSION['url'];
else
$url = "../../index.php";
header("Location:$url");
}
}
}
?>
答案 0 :(得分:0)
我已经更换了错误代码
$user_pass = $row['pass'];
&#13;