【问题标题】:PHP Forgot Password Script [closed]PHP忘记密码脚本[关闭]
【发布时间】:2014-09-02 19:26:14
【问题描述】:

所以,我创建了一个脚本,一个用于登录,一个用于重置用户密码。

代码如下:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Forgot your password?</title>
</head>
<body>
<?php 
error_reporting(0);
$email=$_POST['email'];
if($_POST['submit']=='Send')
{
mysql_connect('localhost','username','password') or die(mysql_error);
mysql_select_db('softlrdl_testlogon');
$query="select * from users where email='$email'";
$result=mysql_query($query) or die(error);
if(mysql_num_rows($result))
{
echo "User exist";
}
else
{
echo "No user exist with this email id";
}
}
?>
<?php
mail(to,subject,message,headers,parameters)
if(mysql_num_rows($result))
{
$code=rand(100,999);
$message="Your activation link is: http://forgot.site.com/forgot.php?email=$email&code=$code
mail($email, "Password Reset Link", $message);
echo "Email sent";
}
else
{
echo "No user exist with this email id";
}
?>
</body>
</html>

我得到的错误是:

Parse error: syntax error, unexpected T_IF in /home/softlrdl/public_html/forgot/forgot.php on line 28

我不知道是什么原因造成的......

提前感谢您的帮助

【问题讨论】:

  • mail() 函数后缺少分号
  • 你应该将你的代码复制到dreamviewer中,它会以红色显示语法错误。它将帮助您找到错误

标签: php html login forgot-password


【解决方案1】:

您有一些语法错误:

  1. 您忘记了mail(to,subject,message,headers,parameters) 的分号
  2. 你忘记了结尾";$message="Your activation link is: http://forgot.site.com/forgot.php?email=$email&amp;code=$code
  3. 您从未真正设置过mail(to,subject,message,headers,parameters) 这些字段中的任何一个

【讨论】:

    【解决方案2】:

    您在这里忘记了分号,但也没有为它们分配任何变量。您最好需要为它们分配变量。但我想你忘记了,如果没有,你需要像下面这样编辑它们:

    $to = "to@mail.com";
    $subject = "yoursubject";
    $message = "yourmessage";
    $headers = "yourheaders";
    $parameters = "yourparameters";
    
    mail($to,$subject,$message,$headers,$parameters);
    

    这里你又忘记了双引号和分号。

    $message= "Your activation link is: http://forgot.site.com/forgot.php?email=$email&code=$code";
    

    【讨论】:

      【解决方案3】:

      缺少分号;邮件后(收件人、主题、邮件、标题、参数)

      【讨论】:

      • 另外,主题,消息,标题,参数需要每个都有$符号。此外,我还没有看到你为这些变量赋值
      猜你喜欢
      • 1970-01-01
      • 2017-04-03
      • 1970-01-01
      • 2013-12-18
      • 2013-08-22
      • 1970-01-01
      • 1970-01-01
      • 2015-04-17
      • 2011-09-28
      相关资源
      最近更新 更多