要求用户的第一件事是登录;如果登录成功,则将用户发送到 index.php,否则;他们被要求重新输入他们的详细信息。
我希望用户登录后用户名显示在 index.php 上;
所以在 index.php 文件中使用 echo 函数到GET登录时的用户名
//check to see if they match
if($username==$dbusername&&$password==$password)
{
$_SESSION['username']=$username;
echo "Welcome '.$username.'";
header('Location: nindex.php');
die();
}
else
echo "incorrect password";
}
else
die("That user does not exist");
}
else
die("please provide a username and password");
?>
Run Code Online (Sandbox Code Playgroud)