我有一个下拉框,用户从中选择一个值。我想将此值发布到将使用它的Map.php。我目前将表单发布到Map.php,这很好 - 但是,我想在用户进行选择并单击按钮后导航到index.php,而不是导航到Map.php。我已经找到了解决方案,但它们似乎都适用于您要访问数据发布到的页面的情况......
userInterface.php
<form name="formname" method="post" action="Map.php">
<div id='userList'>
<?php
//get constants for database
require("database.php");
// Opens a connection to a MySQL server
$connection = mysqli_connect ($server, $username, $password);
$query = "SELECT distinct user FROM route";
$result = mysqli_query($connection, $query);
echo '<select name="dropdown" style="width:400px;">';
$count = 1;
while($r = mysqli_fetch_assoc($result)){
echo "<option value =".$count.">".$r['user']."</option>";
$count++;
}
echo '</select>';
?>
<input type="submit" id="button" value="Get Started!" />
Map.php
$value = $_POST['dropdown'];
if($value==1){....
答案 0 :(得分:0)
只需使用这样的标题:
header('Location: http://www.example.com/');