我有这个页面,当它打开时只是读取一些会话变量并将它们分配给新变量然后取消设置它们,我这样做是为了它们不能被转移到另一个页面。这一切都很好。
但是,我在同一页面上也有一个带有表单的提交按钮。出于某种原因,当我按下提交按钮时,它没有完成它应该完成的查询,只是重用了会话检查代码。这是因为会话变量未设置,因此无法对其进行验证。
为什么它重新运行此会话验证而不运行我的提交按钮代码/
这是页面顶部的会话验证,并且是由于某种原因在单击提交按钮时重新运行的代码
$ahid="";
$bid="";
$np="";
$nt="";
if (isset($_SESSION['ahid'])) {
$ahid = $_SESSION['ahid'];
unset($_SESSION['ahid']);
if (isset($_SESSION['bid'])) {
$bid = $_SESSION['bid'];
unset($_SESSION['bid']);
if (isset($_SESSION['nt'])) {
$nt = $_SESSION['nt'];
unset($_SESSION['nt']);
if (isset($_SESSION['np'])) {
$np = $_SESSION['np'];
unset($_SESSION['np']);
}else{
header('Location: builders.php?hi=1');
exit();
}
}else{
header('Location: builders.php?hi=2');
exit();
}
}else{
header('Location: builders.php?hi=3');
exit();
}
}else{
header('Location: builders.php?hi=4');
exit();
}
这是应该运行的提交按钮代码,但甚至没有被触及
if(isset($_POST['build_chk_finish'])){
$construction_insert = mysql_query("INSERT INTO construction (user_id, estate_id, addon_h_id, builder_id, con_total_price, con_total_time, con_time_started, con_time_ending, con_completed)
VALUES('$user_id', '$estate_id', '$ahid', '$bid', '$np', '$nt', now(), '$future_date', '0')", $general)
or die (mysql_error());
$construction_id = mysql_insert_id();
$con_error="";
$con_error = "Congratualtions! Your Builder has been hired and has begun work.";
$_SESSION['error'] = $con_error;
header("Location: houses.php");
}
只是为了补充信息,当我按下提交按钮时,第一次会话验证失败builders.php?hi=4
。
这是提交按钮
<input name="build_chk_finish" type="submit" class="build_chk_finish" id="bc_submit"/>