我正在嘗試這樣做:當您提交表單時,它會爲您提供一條消息,如「您已被覆蓋到該類並將在幾秒鐘內重定向」然後它重定向到某個頁面。我無法使其工作。這裏是我的代碼:提交表單後重定向到另一個頁面
<html>
<?php
error_reporting(E_ALL); ini_set('display_errors', 1);
$mysql_host = "localhost";
$mysql_username = "";
$mysql_password = "";
$mysql_database = "a";
$mysql_database2 = "";
$sub = $_POST['subject'];
$mysqli2 = new Mysqli($mysql_host, $mysql_username, $mysql_password, $mysql_database2) or die(mysqli_error());
$head = $mysqli2->query("SELECT head FROM class WHERE subject = '$sub'")->fetch_object()->head;
$status = 1;
$mysqli = new Mysqli($mysql_host, $mysql_username, $mysql_password, $mysql_database) or die(mysqli_error());
$prepare = $mysqli->prepare("INSERT INTO `Overrides`(`name`,`mname`,`fname`,`sid`,`email`,`phone`,`sc`,`subject`,`section`,`semester`,`professor`,`status`,`dean`,`head`) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
$prepare->bind_param("ssssssssssssss", $_POST['name'], $_POST['mname'], $_POST['fname'], $_POST['sid'], $_POST['email'], $_POST['phone'], $_POST['Scolarship'], $_POST['subject'], $_POST['section'], $_POST['semester'], $_POST['professor'], $status, $_POST['dean'], $head);
$prepare->execute();
$name = $_POST['name'];
$mname= $_POST['mname'];
$fname = $_POST['fname'];
$email = $_POST['email'];
$semester = $_POST['semester'];
$sid = $_POST['sid'];
$subject = $_POST['subject'];
$section = $_POST['section'];
$professor = $_POST['professor'];
?>
<!DOCTYPE HTML>
<meta charset="UTF-8">
<meta http-equiv="refresh" content="3; url=http://example.com">
<script>
window.location.href = "http://blahblah.com"
</script>
<title>Page Redirection</title>
<!-- Note: don't tell people to `click` the link, just tell them that it is a link. -->
If you are not redirected automatically, follow the <a href='http://blahblah.com'>link to example</a>
<?php
print 'Error : ('. $mysqli->errno .') '. $mysqli->error;
?>
</html>
_I'm無法使它工作._ - 會發生什麼? – Federkun
它立即重定向而不顯示文本。 –