我必须为我学校的学生服务老师建立一个基于约会的系统。到目前为止,我已经为教师和学生建立了登录系统和注册系统。现在,我正在预订系统。

我的PHPMyAdmin数据库中的约会表如下所示:

id (int 11, A.I)
ss_name (int 11) (this is the teacher name, also in the teacher table)
slot_date (date)
client_student_id (int 11) (student id, also in students table)
slot_line (the line in school timetable for appointment to be made)
reason (varhar)
status (varchar)


我的问题是我需要输入学生证号码,老师的姓名,并能够转到该特定老师的下一页。

这是我的PHP代码:

    <?php
     ob_start();
     session_start();
     require_once 'dbconnect.php';

     if( !isset($_SESSION['client']) ) {
      header("Location: homepage_login.php");
      exit;
     }
     // select loggedin users detail
     $res=mysql_query("SELECT * FROM clients WHERE client_id=".$_SESSION['client']);
     $userRow=mysql_fetch_array($res);


     if( isset($_POST['btn-nxt-page']) ) {

      $client_student_id = $_POST['client_student_id'];
      $ss_name = $_POST['ss_name'];

      $client_student_id = strip_tags(trim($client_student_id));
      $ss_name = strip_tags(trim($ss_name));

      $pass = ($client_student_id);

      $res=mysql_query("SELECT client_student_id, ss_name FROM appointments WHERE client_student_id='$client_student_id'");

      $row=mysql_fetch_array($res);

      $count = mysql_num_rows($res); // if uname/pass correct it returns must be 1 row

      if( $count == 1 && $row['client_student_id']==$pass ) {
       $_SESSION['client'] = $row['ss_name'];
       header("Location: homepage_loggedin_book2.php");
      } else {
       $errMSG = "Wrong Credentials, Try again...";
      }
     }
    ?>


这是我的HTML代码:

<div class="form-group">
             <div class="input-group">
             <input type="text" name="client_student_id" class="form-control" placeholder="Enter your Student ID" required />
                </div>
            </div>
            <br>
            <br>

       <label for="ss" id="menu">Select a teacher</label>
            <select name="ss_name" id="#menu">
               <option>John</option>
               <option>Smith</option>
               <option>Greg</option>
               <option>Jess</option>
            </select>
            <br>
            <br>

        <div class="form-group">
             <button type="submit" class="btn btn-block btn-primary" name="btn-nxt-page">Next Page</button>
            </div>

    </div>
  </div>


我的主要问题是:

如何获得在我的HTML代码中选择的特定教师使用预订系统重定向到其他页面的按钮?

最佳答案

您必须使用一些javascript。使用jQuery更好。我会给你一个简单的例子。但是评论中怎么说,这些都是作业...

脚本

<script>
    $(function () {
       $('button[type="submit"]').on('click', function (e) {
           e.preventDefault();
           var url = "http://your_url/" + $('#menu').find(':selected').text();
           window.location.replace(url);
       });
    });
</script>

关于php - 信息填写后的PHP下一页,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/38709554/

10-10 04:01