2009-03-11, 09:59 AM
|
#9 (permalink)
|
長老會員
|
PHP 語法:
<?php
// 取得 HTTP 參數
$flag = $_POST['flag'];
$var_arr = $_POST['var'];
$user = $_POST['user'];
$password = $_POST['pass'];
$line_arr = file("list.txt");
// 是否判斷帳號密碼
if($flag == "login") {
for($index = 0; $index < count($line_arr); $index++) {
$col_arr = explode(",", $line_arr);
if($user == trim($col_arr[0]) && $password == trim($col_arr[1])) {
// 登入成功
echo "5,0," . implode(",", $var_arr);
} else {
// 登入失敗
echo "6,php錯誤代號";
// 寫入一筆新資料
$new_line = implode(",", array($user, $password, $var_arr[2], $var_arr[3], $var_arr[4], $var_arr[5], $var_arr[6], $var_arr[7]));
file_put_contents("list.txt", $new_line . "\n", FILE_APPEND);
}
}
}
?>
<html>
<body>
<form action="test.php" method="POST">
<input type="hidden" name="flag" value="login">
帳號: <input type="text" name="user"><br>
密碼: <input type="password" name="pass"><br>
參數1: <input type="text" name="var[]"><br>
參數2: <input type="text" name="var[]"><br>
參數3: <input type="text" name="var[]"><br>
參數4: <input type="text" name="var[]"><br>
參數5: <input type="text" name="var[]"><br>
參數6: <input type="text" name="var[]"><br>
參數7: <input type="text" name="var[]"><br>
參數8: <input type="text" name="var[]"><br>
<input type="submit" value="submit">
</form>
</body>
</html>
至於資安方面的東西,建議您直接去書店翻書可能會比較快,實在一言難盡
|
__________________
思考,正是從一個錯誤,跳進另外一個錯誤。
|
|
送花文章: 5387,
收花文章: 1361 篇, 收花: 5457 次
|