我有下面的登錄腳本,我認爲這是安全的。但是,有人不斷訪問網站的管理部分並更改內容。登錄不斷被黑客入侵
if(isset($_POST['submit'])) {
$error = false;
$user_login = stripslashes(strip_tags(htmlentities($_POST['user_login'])));
$pass_login = stripslashes(strip_tags(htmlentities($_POST['pass_login'])));
if(!empty($user_login) && !empty($pass_login)) {
$check_details=mysql_query("SELECT * FROM `admin` WHERE email='".$user_login."' AND password='".md5($pass_login)."'");
$status=mysql_num_rows($check_details);
if($status >= "1") {
$error = false;
$_SESSION['wmmadmin_loggedin'] = "1";
$_SESSION['wmmadmin_email'] = "".$user_login."";
header("Location: ./index.php");
}
if(!$status || $status == "0") {
$error = true;
echo "<div id=\"error\"><strong>Error!</strong><br />Login details were incorrect.</div>\n";
}
}
if(empty($user_login) || empty($pass_login)) {
$error = true;
echo "<div id=\"error\"><strong>Error!</strong><br />Enter your username and password.</div>\n";
}
}
在每個腳本的頂部有一個函數調用:
function checkloggedin() {
if($_SESSION['wmmadmin_loggedin'] == "0" || $_SESSION['wmmadmin_loggedin'] !== "1" || $_SESSION['wmmadmin_email'] == "") {
header("Location: login.php");
exit;
}
}
我缺少的東西?我需要阻止這些黑客!
感謝 皮特
您可以[SQL注入](http://stackoverflow.com/q/60174)。謎團已揭開。 – 2013-05-01 16:12:42
您需要使用非棄用函數**(NOT'mysql _ *)重寫** ** – brbcoding 2013-05-01 16:13:30
Phew,'stripslashes(strip_tags(htmlentities($ str)))'是一個有趣的函數 - 您從哪裏得到的? '':-)。使用'mysql_real_escape_string($ str)'代替([see here](http://php.net/manual/en/function.mysql-real-escape-string.php))。 – halfer 2013-05-01 16:14:19