一般的验证方式

//查询某个管理员是否存在
$sql="select*from user1 where name='ls'and password='xxxxxx'";
//看看有没有查询用户
if(查询到){
 header("admin.php");

}else{
 header("login.php");
}

防止sql注入
解决方案
使用预编译
改变验证数据库用户逻辑

$sql="select password from user1 where name='ls'";
看看有没有查询到记录
如果有说明用户存在
if(从数据库查询的密码=用户输入的密码){
 //合法
 head("admin.php");
}else{
 header("ok.php")
}

相关文章: