我需要使用PHP重定向我的selectmenu选项。基本上,我需要能够在选择菜单中选择一名教师,并且在我提交该页面时,它会重定向到特定的教师页面。取决于jQuery selectmenu选择的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));
$count = mysql_num_rows($result);
if ($count) {
$query = "INSERT INTO appointments(client_student_id,ss_name,) VALUES('$client_student_id','$ss_name')";
$res = mysql_query($query);
}
function redirect($where){
header("Location: $where");
}
if ($_REQUEST['ss_name'] == 'John'){
redirect('http://localhost/homepage_loggedin_book_john.php');
}elseif($_REQUEST['ss_name'] == 'Smith'){
redirect('http://localhost/homepage_loggedin_book_smith.php');
}
}
?>
这是我的HTML,你可以看到我有选项,然后在我的PHP我尝试重定向,但它不工作...
<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 value="John">John</option>
<option value="Smith">Smith</option>
<option value="Greg">Greg</option>
<option value="Jess">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>
任何帮助将是真棒。我只是非常需要这个工作,所以我可以继续前进。
如果我不是不够具体:
我需要selectmenu选项能够重定向到一个新的页面选择和提交时。
此外,如果任何人都可以帮助我添加值,我通过selectmenu和文本框输入到我的数据库,这将是真棒!
每次我看到'mysql_ *'和老师在同一个问题的某个地方,我死在里面..请不要再使用它了。它已被弃用超过2年了! – icecub
究竟是什么问题?发生了什么,或什么不是? – Dekel
当我从菜单中选择一个选项并单击提交时,它不会重定向到为特定名称创建的新PHP页面。我只需要它重定向到一个新的页面,当我点击提交基于在菜单中做出的选择 – Isabella