1.html
<!DOCTYPE html>
<html>
<HEADER>
<meta charset="utf-8">
<title>掌控安全官网 - 安全管理从此无忧!| 掌控者-江西网络安全服务与教育提供商!</title>
</HEADER>
<body>
<form action="zy_1.php" method="post">
<input type="name" name="name"/><br>
<input type="password" name="pwd" /><br>
<input type="submit" name="提交">
</form>
</body>
</html>
zy_1.php
<meta charset="utf-8">
<?php
//简单防止SQL注入
function fang_zhu_ru($sql){
$sql = str_replace("select", " ", $sql);//select替换成空
$sql = str_replace("%", "", $sql);
$sql = str_replace("union", "", $sql);
return $sql;
}
$name = $_POST['name'];
$pwd = $_POST['pwd'];
//判断注入
$name=fang_zhu_ru($name);
$pwd=fang_zhu_ru($pwd);
$con = mysqli_connect("localhost","root","root","test");
if(!$con)
{
die('数据库连接失败 '. mysql_eorr());
}
$sql = "select flag from admin where name='$name' and pwd='$pwd'";
$res = mysqli_query($con,$sql);
if (!$res) {
echo "查询出错";
exit();
}
$row = mysqli_fetch_row($res);
// echo $row['0'];
mysqli_close($con);
?>
打赏我,让我更有动力~
© 2016 - 2024 掌控者 All Rights Reserved.
Track-方丈
发表于 2018-7-25
通过,金币奖励已发放。
评论列表
加载数据中...