我的LoginForm存在问题。当我输入登录参数并单击“提交”按钮时 ,用户名和密码字段变为空白,再次单击“提交”按钮,不提供登录的参数....所以我们必须在“提交”按钮上单击两次才能登录
<?php
if(isset($_POST['username']) && isset($_POST['password']))
{
$username = $_POST['username'];
$password = $_POST['password'];
if(!empty($username) && !empty($password))
{
$query = "SELECT id FROM register WHERE username ='$username' AND password='$password'";
$query_run = mysql_query($query);
if($query_run)
{
$query_num_rows = mysql_num_rows($query_run);
if($query_num_rows == 0)
{
echo 'Invalid username/password';
}
else if($query_num_rows == 1)
{
$user_id = mysql_result($query_run,0,'id');
$_SESSION['user_id'] = $user_id;
header('Locaton : index.php');
}
}
}
} ?&GT;
答案 0 :(得分:0)
似乎你拼错了header()函数
更改header('Locaton : index.php');
到header('Location : index.php');