![](https://csdnimg.cn/release/download_crawler_static/86376642/bg7.jpg)
#bottom table a{
color:gray;
font-size:12px;
text-decoration: none;
}
#bottom table a:hover{
color:red;
}
③实现登录功能
if(isset($_POST['sub'])){
require("./public/conn/conn.php");
// 获得用户输入信息
$name=$_POST['name']; // 用户名
$password=$_POST['password']; // 密码
$shenfen=$_POST['shenfen']; // 用户身份
// 防止 sql 注入
$name=$dbh->quote($name);
$password=$dbh->quote($password);
$yzm=$_POST['yzm']; // 用户输入的验证码
@session_start();
$checkstr=@$_SESSION['string']; //获取验证码字符串
// 判断输入是否为空
if(empty($name)||empty($password)||empty($shenfen)||
empty($yzm)){
echo "<script>alert('输入不能为空!');</script>";
}else if(!strcasecmp($yzm, $checkstr)==0){ // 判断验证
码是否输入正确(不区分大小写)
echo "<script>alert('验证码输入错误!');</script>";
}else{
// 判断用户信息是否正确
switch($shenfen){
case '学生':
$sql="SELECT * FROM `095_1` WHERE
`stu_id`=$name AND `stu_pwd`=$password";
break;
case '教师':
$sql="SELECT * FROM `095_2` WHERE
`teacher_id`=$name AND `teacher_pwd`
=$password";
break;
case '管理员':
$sql="SELECT * FROM `095_3` WHERE
`admin_id`=$name AND `admin_pwd`=
$password";
break;