PHP数据库查询

<?php
    session_start();
    if(!isset($_SESSION['count'])){
        $_SESSION['count']=0;
        $_SESSION['expire'] = time();
    }
    @header("X-Powered-By: VSCode");
    
    
    $dbstring = "mysql:host=127.0.0.1;dbname=root";
    $username = "iotcard";
    $passwd = "123456";
    $column_name = "express_query";
    
    $msg = array();
    $personal = array();
    /**
     * 判断AJAX数据传输
     */
       if(!isset($_SERVER["HTTP_X_REQUESTED_WITH"]) || strtolower($_SERVER["HTTP_X_REQUESTED_WITH"])<>"xmlhttprequest"){
           @header("Location:/index.html");
       }

//Redis Server Connection Kit
//     try{
//         $redis = @new Redis();
//         $redis->connect("127.0.0.1",6379);
//     }catch (Exception $e){
//     }
    @header("Content-Type: application/json;charset=utf-8"); //HTTP头用于jq返回
    if($_SESSION['expire'] - time() > 0){
        $msg["status"] = -1;
        $msg["msg"] = "让我喘口气<br>(:з」∠)";
        exit(json_encode($msg));
    }
    try{
        $data = new PDO($dbstring,$username,$passwd);
        $data->query("SET NAMES UTF8");
    }catch(PDOException $e){
        $msg["status"] = -1;
        $msg["msg"] = "数据库君没有起床<br>(:з」∠)";
        exit(json_encode($msg));
    }
    $name = htmlspecialchars(addcslashes($_POST['name'],"\0..\37"));
    $major = htmlspecialchars(addcslashes($_POST['class'],"\0..\37"));;
    $stu_num = htmlspecialchars(addcslashes($_POST['phone_num'],"\0..\37"));;
    $_SESSION['expire'] = time()+10;
    $_SESSION['count']++;
    $pmf = $data->prepare("SELECT * FROM ".$column_name." WHERE name = ? AND phone_num = ? AND class = ?");
    $pmf->bindParam(1,$name,PDO::PARAM_STR);
    //$pmf->bindParam(2,$admission,PDO::PARAM_INT);
    $pmf->bindParam(2,$phone_num,PDO::PARAM_INT);
    $pmf->bindParam(3,$class,PDO::PARAM_INT);
    if($pmf->execute()){
        $arr = $pmf->fetchAll(PDO::FETCH_ASSOC);
        if(count($arr)<>1){
            $msg["status"] = -2;
            $msg["msg"] = "找不到该用户的快递信息~<br>_(:з」∠)_";
            exit(json_encode($msg));
        }else{
               $body = $arr[0];
            $body['status'] = 1;
            $body['msg'] = "OK";
            $body['class_id'] = $body['class'];
            $body['class'] = ($body['class'] < 3)?($body['class'] == 1?"联通":"移动"):($body['class'] < 4)?($body['class'] == 2?"移动":"电信"):"设备专用";
            exit(json_encode($body));
        }
    }else{
        $msg["status"] = -1;
        $msg["msg"] = "数据库君倒下了_<br>(:з」∠)";
        exit(json_encode($msg));
    }
?>