This question already has an answer here:
Why am i getting a mail() error failed to connect to mail server? How can i fix it? I've tried almost everything i could think of. Thank you for your help!
<?php
if (isset($_POST["forgotPass"])) {
$connection = new mysqli("localhost", "root", "", "membershipsystem");
$email = $connection->real_escape_string($_POST["email"]);
$data = $connection->query("SELECT id FROM users WHERE email='$email'");
if ($data->num_rows > 0) {
$str = "0123456789qwertyuiopasdfghjklzxcvbnm";
$str = str_shuffle($str);
$str = substr($str, 0, 10);
$url= "http://ift.tt/2sI7dLR?
token=$str&email=$email";
mail($email, "Reset Password", "To reset your password, please visit
this: $url", "From: example.com\r\n");
$connection->query("UPDATE users SET token='$str' WHERE
email='$email'");
echo "Please check your email!";
}else{
echo "Please check your inputs!";
}
}
?>
Aucun commentaire:
Enregistrer un commentaire