[請益] php網頁會員登入問題
因老師要求必須寫出一個登入網頁並搭配Apache和mysql
而該登入網頁必須可以使用'or 1=1--的sql injection方法入侵!!
我自己寫了一個登入網頁 但是在輸入帳號密碼之後(不論輸入的是否正確)
都會跳回登入的頁面,但是會多了一行:
mysql_fetch_row():supplied argument is not a valid mysql result resource on
line 24
可以請問一下 問題是出在哪邊?該如何解決呢?如果要達到老師的要求
那除了這個問題 我所寫的這個網頁可以達到目標嗎? 感謝回答~"~
以下為我的網頁程式碼:(PS:我的mysql資料庫名稱為member,而資料表為membertest
其中有四個欄位,分別是ID(←主鍵),password,name,mail)
<!-- login.php -->
<html>
<head><title>登入網站</title></head>
<body>
<center>
<h2>輸入使用者名稱和密碼登入網站</h2>
<hr><small><font color="red">
<?
session_start();
session_register("login_session");
$ID = "";
$password = "";
if (isset($_POST["ID"]))
$username = $_POST["ID"];
if (isset($_POST["Password"]))
$password = $_POST["Password"];
if ($ID != "" && $password != "") {
$link = mysql_connect("localhost",“root",“123456");
mysql_select_db("membertest");
$sql = "SELECT * FROM users WHERE ID='.$ID' AND password='.$password'";
$result = mysql_query($sql);
if (mysql_fetch_row($result) != false) {
$_SESSION["login_session"] = true;
header("Location: hellow.php");
} else
echo "名稱或密碼錯誤!<br>";
mysql_close($link);
}
?>
</font></small></center>
<form action="check.php" method="post">
<table align="center" bgcolor="#FFCC99">
<tr><td>使用者名稱 : </td>
<td><input type="text" name="Username" size="15" maxlength="10"></td></tr>
<tr><td>使用者密碼 : </td>
<td><input type="password" name="Password"size="15" maxlength="10"></td></tr>
<tr><td colspan="2" align="center">
<input type="submit" value="登入網站"></td></tr>
</table>
</form>
</body>
</html>
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.129.39.100
→
08/10 01:25, , 1F
08/10 01:25, 1F
→
08/10 01:33, , 2F
08/10 01:33, 2F
→
08/10 01:34, , 3F
08/10 01:34, 3F
→
08/10 01:56, , 4F
08/10 01:56, 4F
→
08/10 02:35, , 5F
08/10 02:35, 5F
→
08/10 12:03, , 6F
08/10 12:03, 6F
→
08/10 12:05, , 7F
08/10 12:05, 7F
→
08/10 19:16, , 8F
08/10 19:16, 8F
→
08/10 19:16, , 9F
08/10 19:16, 9F
→
09/20 04:12, , 10F
09/20 04:12, 10F
→
09/20 04:13, , 11F
09/20 04:13, 11F
討論串 (同標題文章)
PHP 近期熱門文章
PTT數位生活區 即時熱門文章