【发布时间】:2014-05-21 18:02:32
【问题描述】:
我已经阅读了这个网站上的很多答案,但是所有的解决方案都没有解决这个问题。我有代码可以根据他们为调查项目提交的表单数据使用 PHP 重定向页面。标题应根据下拉列表中的用户选择重定向到另一个页面。所有这些都存储在我的本地 WAMP 服务器上的 www 目录中。问题是,页面不会重定向到我在标头重定向中指定的页面,而是重新加载当前页面。我需要它重定向到标题中指定的页面。
这里是 PHP:
<?php
session_start();
if(isset($_POST['post'])) {
$_SESSION['maintasked'] = $_POST['maintask'];
$_SESSION['dated'] = $_POST['date'];
$_SESSION['named'] = $_POST['name'];
session_write_close();
if(!empty($_POST['name']))
{
switch($_POST['maintask']) {
case "Pre Cabinet":
header('Location: /Tier2PreCabinet.php');
exit;
break;
case "At Cabinet":
header('Location: /Tier2AtCabinet.php');
exit;
break;
case "Post Cabinet":
header('Location: /Tier2PostCabinet.php');
exit;
break;
}
}
}
?>
这里是 HTML:
<!doctype html>
<html>
<head>
<meta charset = "utf-8">
<title>Advanced RV Time Records</title>
</head>
<body>
<h2>Advanced RV Time Capsule</h2>
<!-- This form grabs today's date from the JS run at page load and allows the user to change it if necessary -->
<p>Enter the date of the day the work was done.</p>
<form method="post" action="<?=$_SERVER['PHP_SELF']?>">
<input type="date" id="theDate" value="" name ="date">
<!-- This form has the user select the name they will be working under. Must be completed. -->
<p id ="name" name="named">Enter the name of the worker performing the task. </p>
<select id="workers" name="name">
<option value =null></option>
<option>Brian</option>
<option>Mike G.</option>
<option>Anthony</option>
<option>Tom</option>
<option>Joe</option>
<option>Deury</option>
<option>Chris Puetzfeld</option>
<option>Chris Piercy</option>
<option>Frank</option>
</select>
<!-- This form has the user select the task they will be working on.-->
<p>Enter the main task that the worker will be doing</p>
<select id ="MainTask" name ="maintask">
<option id ="1">Pre Cabinet</option>
<option value ="2">At Cabinet</option>
<option value ="3">Post Cabinet</option>
</select>
<input type ="submit" value="Continue On">
</form>
</body>
</html>
【问题讨论】:
-
“你能找到错误”问题are not good questions for Stack Overflow。确保您提供一个简短但对问题的具体说明,准确地告诉我们哪里出了问题。 “它不起作用”不是问题陈述。
-
抱歉,我尝试指定存在的问题。