我不知道我的代码有什么问题,它也不会发送电子邮件。我正在尝试进行密码恢复,而stackoverflow却无济于事。 有人可以帮我吗?
<?php
include 'header.php';
$errors = [];
//Logovanje
if(isset($_POST['submit']))
{
$email = mysqli_real_escape_string($con, $_POST['email']);
// ensure that the user exists on our system
$query = "SELECT email FROM users WHERE email='$email'";
$results = mysqli_query($con, $query);
if (empty($email)) {
array_push($errors, "Your email is required");
}else if(mysqli_num_rows($results) <= 0) {
array_push($errors, "Sorry, no user exists on our system with that email");
}
// generate a unique random token of length 100
$token = bin2hex(random_bytes(50));
if (count($errors) == 0) {
// store token in the password-reset database table against the user's email
$sql = "INSERT INTO password_resets(email, token) VALUES ('$email', '$token')";
$results = mysqli_query($con, $sql);
// Send email to user with the token in a link they can click on
$to = $email;
$subject = "Reset your password on tabloidor.com";
$msg = "Hi there, click on this <a href=\"new-password.php?token=" . $token . "\">link</a> to reset your password on our site";
$msg = wordwrap($msg,70);
$header = "From: tabloidor@incrementcode.com\r\n";
$header.= "MIME-Version: 1.0\r\n";
$header.= "Content-Type: text/html; charset=ISO-8859-1\r\n";
$header.= "X-Priority: 1\r\n";
mail($to, $subject, $msg, $headers);
header('location: pending.php?email=' . $email);
}
}
?>
我没有任何错误。