提交前刷新页面

时间:2017-04-09 19:38:01

标签: javascript php html

我有一个表单,在头标记中使用了一个php标记<?php include_once("insert_emergency_dept.php"); ?>我的表单有action="insert_emergency_dept.php" action="post"...>我有两个这样的页面,每个页面都使用各自包含的php文件。这两个php文件都有一个header(refresh=3; ...)。对我来说奇怪的是,在单击表单按钮而另一页没有单击之前,一页会不断刷新。这是我的php文件的样子,它们是相同的,除了收集的数据和它的去向。

<?php
// Connect to the database
include_once("php_includes/db_connect.php");

// Gather the posted data into local variables
$m = $_POST['MRN'];
$h = $_POST['hospital_name'];
$t = $_POST['trauma_team_activated'];
$i = $_POST['init_ed_diastolic_bp'];

// Get user IP Address
$ip = preg_replace('#[^0-9.]#', '', getenv('REMOTE_ADDR'));

// Form data error handling
if($m == "" || $h == "" || $t == "" || $i == ""){
    echo "The form submission is missing data.";   
} else {
    // End form data error handling
    $sql = "INSERT INTO nys_emergency_dept (mrn, hospital_name, trauma_team_activated, init_ed_diastolic_bp, ip_address, record_insert_dtime)
    VALUES('$m', '$h','$t','$i','$ip', now())";
}

if (mysqli_query($db_connect, $sql)) { 
  echo "Emergency Department Data has been inserted successfully.";
} else {
  printf("Error: %s\n", mysqli_error($db_connect));
}

header("refresh:3; url=emergency_dept.php");
?>

我无法理解为什么在单击表单提交按钮之前不会刷新一个页面,而另一个表单在提交表单之前每隔3秒不断刷新一次。

0 个答案:

没有答案