代码之家  ›  专栏  ›  技术社区  ›  td512

PHP忘记密码脚本〔已关闭〕

  •  -2
  • td512  · 技术社区  · 12 年前

    因此,我创建了一个脚本,一个用于登录,一个用来重置用户密码。

    以下是代码:

    <!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 回复  |  直到 12 年前
        1
  •  2
  •   Burak    12 年前

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

    $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";
    
        2
  •  0
  •   keeplearningtocode    12 年前

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

        3
  •  0
  •   Tim    12 年前

    您有一些语法错误:

    1. 您忘记了分号 mail(to,subject,message,headers,parameters)
    2. 你忘了结局 " ; $message="Your activation link is: http://forgot.site.com/forgot.php?email=$email&code=$code
    3. 你从未真正设定 邮件(收件人、主题、邮件、标题、参数) 任何这些字段
    推荐文章