PHP忘记密码脚本

时间:2014-07-12 05:58:38

标签: php html login forgot-password

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

以下是代码:

<!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

我不知道是什么导致它......

感谢您的提前帮助

3 个答案:

答案 0 :(得分: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";

答案 1 :(得分:0)

缺少分号;邮件(到,主题,消息,标题,参数)之后

答案 2 :(得分:0)

您有一些语法错误:

  1. 您忘记了mail(to,subject,message,headers,parameters)
  2. 上的分号
  3. 您忘记了"
  4. 处的结尾;$message="Your activation link is: http://forgot.site.com/forgot.php?email=$email&code=$code
  5. 您实际上从未实际设置mail(to,subject,message,headers,parameters)任何这些字段