PHP - 密码重置不起作用

时间:2017-12-05 20:49:51

标签: php passwords reset

我是PHP的新手,我知道这段代码并不完美,但我想尝试一些事情,现在我遇到了问题:

error_reporting(E_ALL);
ini_set('display_errors', 1);

include "../../pdo_connect.php";

$submit = $_POST["submit"];

if($submit != 1) {

    $id = $_GET["id"];
    $token = $_GET["tk"];

    $getinfoquery = "SELECT email from passreset WHERE resid = ? AND restoken = ?";

    $getinfostmt = $pdo_log->prepare($getinfoquery);
    $getinfostmt->execute(array(
        $id,
        $token
    ));

    while(true) {

        $info = $getinfostmt->fetch(PDO::FETCH_ASSOC);

        if(empty($info)) {
            echo "This link doesn't work";
            break;
        } else if(!empty($info)) {
            $email = $info["email"];
            ?>  
                <div id="badPasswordText" style="display: none"></div>

                <form method="POST" action="">
                    New Password         <input type="password" name="newpass"><br/>
                    Reenter new Password <input type="password" name="newpassB"><br/>
                    <input type="hidden" value="1" name="submit"> 
                    <input type="hidden" value="<?php echo '$email'; ?>" name="email">
                    <input type="submit" value="Change"><br/><br/>
                </form>
                <form method="POST" action="">
                    <input type="hidden" value="1" name="submit">
                    <input type="hidden" value="1" name="cancel">
                    <input type="submit" value="Cancel">
                </form>
            <?php
            break;
        }
    }

} else if($submit == 1) {

    $cancel = $_POST["cancel"];

    if($cancel == 1) {
        echo "<script> window.location = '##Deleted this link##'; </script>";
    } else {

        $newpass = $_POST["newpass"];
        $newpassB = $_POST["newpassB"];
        $email = $_POST["email"];

        $newpasshash = password_hash($newpass, PASSWORD_BCRYPT);
        $newpassBhash = password_hash($newpassB, PASSWORD_BCRYPT);

        if(password_verify($newpasshash, $newpassBhash)) {

            $updatequery = "UPDATE user SET password = ? WHERE email = ?";

            $updatestmt = $pdo_log->prepare($updatequery);
            $updatestmt->execute(array(
                $newpasshash,
                $email
            ));

            $deletequery = "DELETE FROM passreset WHERE email = ?";

            $deletestmt = $pdo_log->prepare($deletequery);
            $deletestmt->execute(array(
                $email
            ));

            echo "Successful! ";
            ?><a href="##Deleted this link##">Continue</a><?php

        } else {
            echo "<script>badPassword();</script>";
        }
    }

}

此代码是密码重置功能的一部分。一切正常,如果用户输入新密码并单击“更改”,则会出现唯一的问题。然后它只显示一个空白站点。我想我在这里有某种逻辑错误,但我不知道它在哪里......

也许你可以帮我解决这个问题!

错误日志:

[Tue Dec 05 00:49:44 2017] [error] [client 66.249.64.195] File does not exist: /var/customers/webs/ni873420_2/robots.txt
[Tue Dec 05 04:52:09 2017] [error] [client 5.45.207.40] File does not exist: /var/customers/webs/ni873420_2/robots.txt
[Tue Dec 05 07:51:18 2017] [error] [client 37.9.113.143] File does not exist: /var/customers/webs/ni873420_2/robots.txt
[Tue Dec 05 09:52:06 2017] [error] [client 66.249.64.143] File does not exist: /var/customers/webs/ni873420_2/robots.txt
[Tue Dec 05 10:31:41 2017] [error] [client 95.108.213.23] File does not exist: /var/customers/webs/ni873420_2/robots.txt
[Tue Dec 05 12:19:06 2017] [error] [client 95.108.213.23] File does not exist: /var/customers/webs/ni873420_2/robots.txt
[Tue Dec 05 13:52:15 2017] [error] [client 95.108.213.23] File does not exist: /var/customers/webs/ni873420_2/robots.txt
[Tue Dec 05 14:09:08 2017] [error] [client 95.108.213.23] File does not exist: /var/customers/webs/ni873420_2/robots.txt
[Tue Dec 05 14:10:16 2017] [error] [client 95.108.213.23] File does not exist: /usr/share/doc/apache2-doc/manual/tr/mod/mod_auth_anon.html
[Tue Dec 05 14:11:21 2017] [error] [client 95.108.213.23] File does not exist: /usr/share/doc/apache2-doc/manual/tr/mod/mod_auth.html
[Tue Dec 05 14:12:04 2017] [error] [client 95.108.213.23] File does not exist: /usr/share/doc/apache2-doc/manual/tr/mod/mod_access.html
[Tue Dec 05 14:51:13 2017] [error] [client 95.108.213.23] File does not exist: /usr/share/doc/apache2-doc/manual/tr/ru
[Tue Dec 05 15:59:39 2017] [error] [client 95.108.213.23] File does not exist: /var/customers/webs/ni873420_2/robots.txt
[Tue Dec 05 16:50:40 2017] [error] [client 95.108.213.23] File does not exist: /var/customers/webs/ni873420_2/robots.txt
[Tue Dec 05 19:20:24 2017] [error] [client 95.108.213.23] File does not exist: /var/customers/webs/ni873420_2/robots.txt
[Tue Dec 05 19:21:40 2017] [error] [client 95.108.213.23] File does not exist: /usr/share/doc/apache2-doc/manual/tr/ru
[Tue Dec 05 20:20:32 2017] [error] [client 66.249.64.198] File does not exist: /var/customers/webs/ni873420_2/robots.txt
[Tue Dec 05 20:32:30 2017] [warn] [client 91.113.119.184] mod_fcgid: stderr: PHP Parse error: syntax error, unexpected '{' in /var/customers/webs/ni873420_2/login/reset/index.php on line 26, referer: http://www.website.com/login/
[Tue Dec 05 20:32:30 2017] [error] [client 91.113.119.184] File does not exist: /var/customers/webs/ni873420_2/favicon.ico, referer: http://www.website.com/login/reset/
[Tue Dec 05 20:57:39 2017] [warn] [client 91.113.119.184] mod_fcgid: stderr: PHP Parse error: syntax error, unexpected '{' in /var/customers/webs/ni873420_2/login/reset/changepass.php on line 90
[Tue Dec 05 20:58:12 2017] [error] [client 95.108.213.23] File does not exist: /var/customers/webs/ni873420_2/robots.txt
[Tue Dec 05 20:59:36 2017] [warn] [client 91.113.119.184] mod_fcgid: stderr: PHP Fatal error: Call to undefined method PDOStatement::exec() in /var/customers/webs/ni873420_2/login/reset/changepass.php on line 37
[Tue Dec 05 21:05:31 2017] [error] [client 95.108.213.23] File does not exist: /var/customers/webs/ni873420_2/robots.txt
[Tue Dec 05 21:35:06 2017] [warn] [client 91.113.119.184] mod_fcgid: stderr: PHP Notice: Undefined index: submit in /var/customers/webs/ni873420_2/login/reset/changepass.php on line 30
[Tue Dec 05 21:56:38 2017] [warn] [client 91.113.119.184] mod_fcgid: stderr: PHP Notice: Undefined index: submit in /var/customers/webs/ni873420_2/login/reset/changepass.php on line 30
[Tue Dec 05 21:56:44 2017] [warn] [client 91.113.119.184] mod_fcgid: stderr: PHP Notice: Undefined index: cancel in /var/customers/webs/ni873420_2/login/reset/changepass.php on line 82, referer: http://www.website.com/login/reset/changepass.php?id=7dNGokCyEu&tk=sDm5IE8UhjSrzawWakRejr0ae584744AIqFr4Nlm
[Tue Dec 05 21:59:54 2017] [warn] [client 91.113.119.184] mod_fcgid: stderr: PHP Notice: Undefined index: submit in /var/customers/webs/ni873420_2/login/reset/changepass.php on line 30
[Tue Dec 05 21:59:58 2017] [warn] [client 91.113.119.184] mod_fcgid: stderr: PHP Notice: Undefined index: cancel in /var/customers/webs/ni873420_2/login/reset/changepass.php on line 82, referer: http://www.website.com/login/reset/changepass.php?id=7dNGokCyEu&tk=sDm5IE8UhjSrzawWakRejr0ae584744AIqFr4Nlm
[Tue Dec 05 22:02:17 2017] [warn] [client 91.113.119.184] mod_fcgid: stderr: PHP Notice: Undefined index: submit in /var/customers/webs/ni873420_2/login/reset/changepass.php on line 30
[Tue Dec 05 22:02:21 2017] [warn] [client 91.113.119.184] mod_fcgid: stderr: PHP Notice: Undefined index: cancel in /var/customers/webs/ni873420_2/login/reset/changepass.php on line 82, referer: http://www.website.com/login/reset/changepass.php?id=7dNGokCyEu&tk=sDm5IE8UhjSrzawWakRejr0ae584744AIqFr4Nlm
[Tue Dec 05 22:04:34 2017] [error] [client 37.9.113.67] File does not exist: /usr/share/doc/apache2-doc/manual/tr/ru
[Tue Dec 05 22:04:37 2017] [error] [client 66.249.64.145] File does not exist: /var/customers/webs/ni873420_2/robots.txt
[Tue Dec 05 22:05:39 2017] [error] [client 95.108.213.23] File does not exist: /usr/share/doc/apache2-doc/manual/es/ru
[Tue Dec 05 22:07:39 2017] [warn] [client 91.113.119.184] mod_fcgid: stderr: PHP Notice: Undefined index: cancel in /var/customers/webs/ni873420_2/login/reset/changepass.php on line 82, referer: http://www.website.com/login/reset/changepass.php?id=7dNGokCyEu&tk=sDm5IE8UhjSrzawWakRejr0ae584744AIqFr4Nlm

0 个答案:

没有答案