Re: [請益] php網頁會員登入問題
這兩天 小弟參考了各位大大的建議 也自己去找了一些書籍來看
目前在登入的部分 似乎沒有什麼問題了 可以正常登入
但是還有一個問題 我試了很久還是搞不出來 是有關sql injection的部分
是希望能夠透過簡單的隱碼攻擊 (EX: 'or 1=1--)這種 來達到登入的目的
不知各位高手們 能賜教一下嗎??
感謝!!
--------------------以下為目前修改後的原始碼----------------------
<!--範例程式:>
<html>
<head><title>login</title></head>
<body>
<center>
<h2>ID&&PassWord</h2>
<hr><small><font color="red">
<?
session_start();
session_register("login_session");
$ID="";
$Password="";
if(isset($_POST["ID"]))
$ID=$_POST["ID"];
if(isset($_POST["Password"]))
$Password=$_POST["Password"];
if($ID!="")
{
$link=mysql_connect("localhost","sosokill","sosokill");
mysql_select_db("member");
$sql="SELECT *FROM membertest WHERE ID='".$ID."' AND
Password='".$Password."'";
$result=mysql_query($sql);
$Fields=mysql_fetch_array($result);
if($Fields["ID"]==$ID && $Fields["Password"]==$Password){
$_SESSION["login_session"]=true;
header("location:hello.php");
}else
echo "<br>Password error<br>";
mysql_close($link);
}
?>
</font></small></center>
<form action="check.php" method="post">
<table align="center" bgcolor="#FFCC99">
<tr><td>username:</td>
<td><input type="text" name="ID" size="15" maxlength="10"></td></tr>
<tr><td>password:</td>
<td><input type="password" name="Password" size="15" maxlength="10"></td></tr>
<tr><td colspan="2" align="center">
<input type="submit" value="login"></td></tr>
</table>
</form>
</body>
</html>
-----------------------------------------------------------------------------
有試過將WHERE ID='".$ID."' AND Password='".$Password."'";
改成WHERE ID='".$ID."'";
但是沒用= =
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.129.39.100
※ 編輯: sosokill 來自: 140.129.39.100 (08/10 23:47)
※ 編輯: sosokill 來自: 140.129.39.100 (08/11 01:22)
推
08/11 01:37, , 1F
08/11 01:37, 1F
→
08/11 01:38, , 2F
08/11 01:38, 2F
→
08/11 01:39, , 3F
08/11 01:39, 3F
→
08/11 01:40, , 4F
08/11 01:40, 4F
推
08/11 02:46, , 5F
08/11 02:46, 5F
→
08/11 02:47, , 6F
08/11 02:47, 6F
→
08/11 02:47, , 7F
08/11 02:47, 7F
我將IF($Fields["ID"]==$ID && $Fields["Password"]==$Password)這段
改成IF($result==true)
結果是 不論輸入啥 都可以成功登入 囧
※ 編輯: sosokill 來自: 140.129.39.100 (08/11 03:23)
推
08/11 13:26, , 8F
08/11 13:26, 8F
→
08/11 13:26, , 9F
08/11 13:26, 9F
→
08/11 13:29, , 10F
08/11 13:29, 10F
→
08/11 17:45, , 11F
08/11 17:45, 11F
→
08/11 19:35, , 12F
08/11 19:35, 12F
→
08/11 22:54, , 13F
08/11 22:54, 13F
→
08/11 22:55, , 14F
08/11 22:55, 14F
→
08/11 22:55, , 15F
08/11 22:55, 15F
討論串 (同標題文章)
PHP 近期熱門文章
PTT數位生活區 即時熱門文章