-1

这是我的脚本:

我知道我只是通过电子邮件登录,而不是检查密码。这仅用于测试目的。

我登录成功,显示表单以搜索用户名。单击“验证帐户”链接后,我将失去会话。如果我在登录后刷新页面,也会发生同样的情况。

为什么是这样?

<?php
$session_start;
mysql_connect ('localhost', 'root', '') ;
mysql_select_db ('findaduo');
if(isset($_POST['login'])) {
    $email = mysql_real_escape_string($_POST['email']);
    $password = mysql_real_escape_string($_POST['password']);
    $id = mysql_fetch_assoc(mysql_query("SELECT * FROM users WHERE email = '$email' "));
    $_SESSION['id'] = htmlspecialchars($id["id"]); 
}
?>
<html>
<body>
    <?php 
    if(isset($_SESSION['id'])) {
    echo 
        'Welcome back, ' . $id["username"] .
        '<form method="GET" action="profile.php">
            Search Username: <input type="text" name="username" /><br />
            <input type="submit" value="Submit" />
        </form><br />' 
        . 'Before you can search duos, you need to <a href="verify_leagueaccount.php">verify your account.</a>'
        ;
        $die;
    }
    else {
        echo '
            <form method="POST" action="index.php">
            <h4>Login</h4>
            <input type="text" name="email" placeholder="Email" /><br />
            <input type="password" name="password" placeholder="Password" /><br />
            <input type="submit" value="Login" name="login" /><br />
            </form>
            <a href="register.php">Register</a>
        ';
        $die;
    }
    //echo $id["id"];
    exit;
    ?>
</body>
</html>
4

1 回答 1

5

session_start();不是$session_start;

于 2013-08-27T04:03:53.350 回答