我的 signin.html 只是一个带有用户名和密码字段的普通 html 页面..nd 一个登录按钮..我只想在上一个 signin.html 页面的 echo 下显示所有这些错误消息。 logincheck.php 的代码如下:
<?php
session_start();
$username = $_POST['username'];
$password = $_POST['password'];
if($username && $password)
{
$connect = mysql_connect("localhost","root","") or die("Couldn't connect!");
mysql_select_db("project") or die("Couldn't find db");
$query= mysql_query("SELECT * From signup1 WHERE username='$username'");
$numrows = mysql_num_rows($query);
if ($numrows!=0)
{
//code to login
while ($row = mysql_fetch_assoc($query))
{
$dbusername = $row['username'];
$dbpassword = $row['password'];
}
if($username==$dbusername&&$password==$dbpassword)
{
$_SESSION['username']=$username;
header('Location:mailbox.php');
}
else
echo "Incorrect password!";
}
else
die("That user does't exist!");
}
else
die("Please enter username and Password!");
if($_SESSION['username'])
echo "Welcome, " .$_SESSION['username']."!<br><a href='logout.php'>Logout</a><br> ";
else
die ("You must be logged in!");
?>