PHP cURL-普通话等级考试查询系统

乾坤 2020-1-12

index.html


<html>
<head>
  <title>普通话等级考试查询</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
  <meta name="description" content="普通话等级考试查询">
  <style type="text/css">
    *{margin: 0;padding: 0;border: 0;}
    body{background-color: rgb(240,240,240);font-family: Microsoft YaHei;}
            .mandarin_p{width: 100%;height: 50px;margin: 20px auto;background-color: rgb(255,255,255);}
            .mandarin_input{width: 100%;height: 50px;float: left;display: block;padding-left: 10%;font-family: Microsoft YaHei;outline: none;}
            .mandarin_sub{width: 100%;height: 50px;margin: 20px auto;}
            .mandarin_btn{display: block;margin: 0 auto;width: 95%;height: 100%;font-family: Microsoft YaHei;background-color: rgb(90,215,0);color: #fff;font-size: 16px;}
  </style>
</head>
<body>
  <form method="post" action="mandarin_query.php">
            <p align="center" style="font-size: 12px;margin-top: 20px;">请至少输入你的姓名、准考证号、身份证号中任意两项</p>
            <p class="mandarin_p">
            <input class="mandarin_input" name="name" type="text" placeholder="考生姓名" maxlength="30" value="">
      </p>
      <p class="mandarin_p">
            <input class="mandarin_input" name="stuID" type="number" placeholder="准考证号" maxlength="30" value="">
      </p>
      <p class="mandarin_p">
            <input class="mandarin_input" name="idCard" type="text" placeholder="身份证" maxlength="30" value="">
      </p>
      <p class="mandarin_sub">
            <input id='show-toast' class="mandarin_btn" type="submit" value="查询" οnclick="return form_onsubmit(this.form)" />
      </p>
  </form>
  <script type="text/javascript">
      function form_onsubmit(obj) 
      {   
            if(obj.name.value == "" && obj.stuID.value =="" && obj.idCard.value == "") {
            alert("亲~请至少输入任意两项!");
            return false;
          } 
 
          if(obj.name.value !== "" && obj.stuID.value =="" && obj.idCard.value == "") {
            alert("亲~请至少输入任意两项!");
            return false;
          }
 
          if(obj.name.value == "" && obj.stuID.value !=="" && obj.idCard.value == "") {
            alert("亲~请至少输入任意两项!");
            return false;
          }
 
          if(obj.name.value == "" && obj.stuID.value =="" && obj.idCard.value !== "") {
            alert("亲~请至少输入任意两项!");
            return false;
          }
 
          else{
            // $(document).on("click", "#show-toast", function() {
            //   $.toast("操作成功", function() {
            //     console.log('close');
            //   });
            // })
            return true;
          }
      }
  </script>
</body>
</html>
 
<p align="center" style="font-size: 12px;margin-top: 20px;">校园令普通话查询</p>

mandarin_query.php


  1. <meta charset="utf-8">
    <?php
        header("Content-type:text/html,charset=utf8");
        $url = 'http://www.cltt.org/StudentScore/ScoreResult';
     
        $name = $_POST['name'];
        $stuID = $_POST['stuID'];
        $idCard = $_POST['idCard'];
     
        $data = array (
            'name' => $name,
            'stuID' => $stuID,
            'idCard' => $idCard
        );
     
        $ch = curl_init();
        $timeout = 5;
        curl_setopt ($ch, CURLOPT_URL, $url);
        curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt ($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)");
        curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
        curl_setopt ($ch, CURLOPT_POST, 1 );//请求方式为post
        curl_setopt ($ch, CURLOPT_POSTFIELDS, $data );//post传输的数据
        curl_setopt ($ch, CURLOPT_REFERER, 'http://www.cltt.org/studentscore');
        $contents = curl_exec($ch);
     
        curl_close($ch);
        print_r($contents);
     
    ?>
    

Comments | 0 条评论