我想知道应该添加些什么以使该系统更安全,因为'or'1'='1很容易 闯入它。为了阻止人员干扰查询,我需要声明哪些参数?预先感谢。
<?php
session_start();
$_SESSION['user'] = ($_POST['user']);
$user=$_POST['user'];
$pass=$_POST['pass'];
$conexion=mysqli_connect('localhost', 'root', 'asdf', 'aspirantes');
$consulta="SELECT * FROM users WHERE users='$user' AND pass='$pass'";
$resultado=mysqli_query($conexion, $consulta);
$rows=mysqli_num_rows($resultado);
if($rows>0){
header("location:index.php");
}
else{
header("location:login.html");
}
mysqli_free_result($resultado);
mysqli_close($conexion);
?>
我的数据库:
CREATE TABLE IF NOT EXISTS `users` (
`id` int(11) NOT NULL,
`user` varchar(50) DEFAULT NULL,
`pass` varchar(50) DEFAULT NULL
) ENGINE=InnoDB AUTO_INCREMENT=16 DEFAULT CHARSET=utf8;