我在練習簡單的登入畫面,這是登入的程式
<html>
<head>
<title>命名檔 login.htm </title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<form method="post" action="checkuser.php">
帳號:<input type=text name=id><br>
密碼:<input type=password name=pass>
<input type=submit name=btn value=登入>
</form>
</body>
</html>
下面是檢查使用者帳號或密碼的程式
<?php
$db_link = mysqli_connect("localhost", "root", "12345678");
mysqli_query($db_link , "set names utf8");
$seldb = @mysqli_select_db($db_link, "secure");
$con=mysqli_connect("127.0.0.1","root","12345678","secure") or die("Database not connected");
$Query = mysqli_query($con,$sql);
$id=$_POST["id"];
$pass=$_POST["pass"];
$sql="SELECT * FROM usertb WHERE id='$id' AND pass='$pass'";
if (!mysqli_fetch_row($Query))
{
echo "帳號或密碼錯誤~!!!<br>";
echo "$id---$pass";
include "login.htm";
exit;
}
else
header("location:http://localhost/phptest/secure/loginok.php?id=$id&pass=$pass");
?>
想請問為什麼帳號密碼都確定輸入正確了,他還是顯示帳號或密碼錯誤呢?