0

こんにちは、これは私がサイトのガビングをほぼ完了したところですが、なぜこのパスワードのリセットページがその手順を経ていないのか頭を悩ませています. それもまたマイナーなものだと確信していますが、見ることができません。リセットボタンがまったく機能していないように見えますが、呼び出したときの正しいスペルと、私が知る限りすべての括弧が正しいです。これらのエラーに慣れれば慣れるほど、自分でエラーをキャッチするのが難しくなります。ばかげた質問をお詫びします。

これが私のコードです:

<?php
error_reporting (E_ALL ^ E_NOTICE);
session_start();
$userid = $_SESSION['userid'];
$username = $_SESSION['username'];
?>
<html>
<head>
<title> Member system : Forgot password</title>
</head>
<body>
<?php
if(!$username && !$userid) {

    if($_POST['resetbtn']) {
        //get form data
        $user = $_POST['user'];
        $email = $_POST['email'];

        //make sure info provided
        if($user) {
            if($email) {
                if((strlen($email) > 7) && (strstr($email, "@")) &&    (strstr($email, ".")) ) {
                    require("./connect.php");

                    $query = mysql_query("SELECT * FROM user WHERE   username='$user'");
                    $numrows = mysql_num_rows($query);
                    if($numrows == 1) {
                        // info about account
                        $row = mysql_fetch_assoc($query);
                        $dbemail = $row['email'];

                        //make sure email is correct
                        if($email == $dbemail) {
                            // generate a password
                            $pass = rand();
                            $pass = md5($pass);
                            $pass = substr($pass, 0, 15);
                            $password =   md5(md5("12345".$pass."54321"));

                            //update db with new pass
                            mysql_query("UPDATE user SET  password='$password' WHERE username='$user'");

                            //make sure password was changed
                            $query = mysql_query("SELECT * FROM  user WHERE username='$user' AND password='$password'");
                            $numrows = mysql_num_rows($query);
                            if($numrows == 1) {
                                //create our email variables
                                $webmaster =  "mwilkins877@gmail.com";
                                $headers = "From:  Mike<$webmaster>";
                                $subject = "Your new password";
                                $message = "Your password has been reset, your new password is below. \n";
                                $message .= "Password: $pass\n";

                                echo $pass."<br/>";
                                if(mail($email, $subject, $message, $headers)) {
                                    echo "Your password has been reset an email has been sent with your new password";
                                }
                                else
                                    echo "An error has occured and your email wasnt sent containing your new password";
                            }
                            else
                                echo "An error has occured and the password was not set";
                        }
                        else
                            echo "You have entered the wrong email address";

                    }
                    else 
                        echo "The user name was not found";

                    mysql_close();
                }
                else "Please enter a valid email address";
            }
            else
                echo "please enter your email";
        }
        else
            echo "Please enter your user name";
    }
    else
        echo"<from action='./forgotpass.php' method='post'>
        <table>
        <tr>
            <td>User name</td>
            <td><input type='text' name='user'/></td>
        </tr>
        <tr>
            <td>email</td>
            <td><input type='text' name='email'/></td>
        </tr>
        <tr>
            <td></td>
            <td><input type='submit' name='resetbtn' value='Reset password'/>  </td>
        </tr>
        </table>
        </form>";
}
else
    echo "Please log out to view this page";
?>
</body>
</html>

私だけが楽しみのために学んでいるので、これについてあなたの助けをいただければ幸いです。うまくいけば、誰かの返事を楽しみにしています。前もって感謝します。

4

2 に答える 2

5

フォームのスペルを修正してください

echo"<from action='./forgotpass.php' method='post'>

echo"<form action='./forgotpass.php' method='post'>

これで問題が解決することを願っています

于 2013-03-12T12:29:35.207 に答える
0

これを試してみてください。それは私のために働いています。

<?php
error_reporting (E_ALL ^ E_NOTICE);
session_start();
$userid = $_SESSION['userid'];
$username = $_SESSION['username'];
?>
<body>
<?php
if(!$username && !$userid) {

    if($_POST['resetbtn']) {
        //get form data
        $user = $_POST['user'];
        $email = $_POST['email'];

        //make sure info provided
        if($user) {
            if($email) {
                if((strlen($email) > 7) && (strstr($email, "@")) &&    (strstr($email, ".")) ) {
                    require("./connect.php");

                    $query = mysql_query("SELECT * FROM user WHERE   username='$user'");
                    $numrows = mysql_num_rows($query);
                    if($numrows == 1) {
                        // info about account
                        $row = mysql_fetch_assoc($query);
                        $dbemail = $row['email'];

                        //make sure email is correct
                        if($email == $dbemail) {
                            // generate a password
                            $pass = rand();
                            $pass = md5($pass);
                            $pass = substr($pass, 0, 15);
                            $password =   md5(md5("12345".$pass."54321"));

                            //update db with new pass
                            mysql_query("UPDATE user SET  password='$password' WHERE username='$user'");

                            //make sure password was changed
                            $query = mysql_query("SELECT * FROM  user WHERE username='$user' AND password='$password'");
                            $numrows = mysql_num_rows($query);
                            if($numrows == 1) {
                                //create our email variables
                                $webmaster =  "mwilkins877@gmail.com";
                                $headers = "From:  Mike<$webmaster>";
                                $subject = "Your new password";
                                $message = "Your password has been reset, your new password is below. \n";
                                $message .= "Password: $pass\n";

                                echo $pass."<br/>";
                                if(mail($email, $subject, $message, $headers)) {
                                    echo "Your password has been reset an email has been sent with your new password";
                                }
                                else
                                    echo "An error has occured and your email wasnt sent containing your new password";
                            }
                            else
                                echo "An error has occured and the password was not set";
                        }
                        else
                            echo "You have entered the wrong email address";

                    }
                    else 
                        echo "The user name was not found";

                    mysql_close();
                }
                else "Please enter a valid email address";
            }
            else
                echo "please enter your email";
        }
        else
            echo "Please enter your user name";
    }
    else
        echo"<form action='./forgotpass.php' method='post'>
        <table>
        <tr>
            <td>User name</td>
            <td><input type='text' name='user'/></td>
        </tr>
        <tr>
            <td>email</td>
            <td><input type='text' name='email'/></td>
        </tr>
        <tr>
            <td></td>
            <td><input type='submit' name='resetbtn' value='Reset password'/>  </td>
        </tr>
        </table>
        </form>";
于 2013-03-12T12:49:51.647 に答える