gpt4 book ai didi

javascript - 忘记密码 php 中的代码不起作用

转载 作者:行者123 更新时间:2023-12-03 07:27:22 25 4
gpt4 key购买 nike

我有用 php 编写的忘记密码的代码。但它不起作用。每当我执行它时,它都会显示邮件已发送到特定电子邮件。但没有发送任何邮件。这是代码

<?php
include('./connect1.php');
$username = $_GET['user'];
$password = $_GET['pass'];
$email = "";
$sql = "SELECT email FROM users WHERE username='$username'";
$result = mysqli_query($conn, $sql);
if(mysqli_num_rows($result)>0){
$row = mysqli_fetch_assoc($result);
$email = $row['email'];
}
else{
echo "no such user exists";
}
$to = $email;
$from = "gopal@gmail.com";
$message = "
<html>
<head>
<title>Password Reset</title>
</head>
<body>
<p>Please click on this link to reset your passowrd</p>
<a href='www.someone.com/login/reset.php?user=".$username."'>Reset Password</a>
</body>
</html>
";
$subject = "Password Reset";
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";

// More headers
$headers .= 'From: <gopal@gmail.com>' . "\r\n";
mail($to,$subject,$message,$headers);
echo '<script>alert("Password reset mail has been sent to'.$email.'");</script>';
?>

请帮帮我。

最佳答案

这可能是一个配置错误。如果您坚持使用PHP邮件功能,则必须编辑php.ini。

如果您正在寻找更简单、更通用的选项(在我看来),您应该使用 PHPMailer

关于javascript - 忘记密码 php 中的代码不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35945735/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com