我的忘记密码页面出现问题。当我输入我的电子邮件地址并单击提交时,我将被带到一个空白页面,并且不会发送包含我的密码的电子邮件。任何帮助表示赞赏。谢谢!
<?php
include 'db.php';
if(isset($_POST['submit']))
{
$email_address=$_POST['email_address'];
$q=mysql_query("select * from login where email_address='".$email_address."' ") or die(mysql_error());
$p=mysql_affected_rows();
if($p!=0)
{
$res=mysql_fetch_array($q);
$to=$res['email_address'];
$subject='YNAGS Password Recovery';
$message='Your password : '.$res['password'];
$headers='From:password_reset@ynags.com';
$m=mail($to,$subject,$message,$headers);
if($m)
{
echo'Check your inbox in mail';
}
else
{
echo'mail is not send';
}
}
else
{
echo'You entered mail id is not present';
}
}
?>
我不太确定这是什么:
$q=mysql_query("select * from login where email_address='".$email_address."' ") or die(mysql_error());
主要是此声明的登录部分。
答案 0 :(得分:0)
1. We should know the code from db.php (obviously without the sensitive data).
2. Try something like this:
db.php
<?php
define("HOST", "your host");
define("USER", "db user name");
define("NAME", "db name");
define("PASSWORD", "password");
?>
forgot.php
<?php
include("db.php");
if(isset($_POST['email_address'])){
$email_address = $_POST['email_address'];
$con = mysqli_connect(HOST, USER, PASSWORD, NAME);
$sql = "SELECT * FROM login WHERE email_address = '".$email_address."'";
if(mysqli_affected_rows(mysqli_query($con, $sql)) != 0){
$res = array();
$res = mysqli_fetch_array(mysqli_query($con, $sql));
$to = $res['email_address'];
// and so on ...
}else{
echo "Email not found";
}
}else{
echo "Form not submitted";
}
?>