我在将一些数据提交到我的数据库到 example.php 后尝试重定向我有表单并且它提交完美但无法让重定向工作我尝试了一些我在互联网上看到的方法但没有任何效果
<html>
<head>
<title>MySQLi Create Record</title>
</head>
<body>
<?php
$action = isset($_POST['action']) ? $_POST['action'] : "";
if($action=='create'){
//include database connection
include 'db_connect.php';
//write query
$query = "insert into referb
set
make = '".$mysqli->real_escape_string($_POST['make'])."',
model = '".$mysqli->real_escape_string($_POST['model'])."',
unitt = '".$mysqli->real_escape_string($_POST['unitt'])."'";
if( $mysqli->query($query) ) {
echo " header( 'Location: example.php' ) ;";
}else{
echo "Database Error: Unable to create record.";
}
$mysqli->close();
}
?>
<!--we have our html form here where user information will be entered-->
<form action='#' method='post' border='0'>
<table>
<tr>
<td>Manufactor</td>
<td><input type='text' name='make' /></td>
</tr>
<tr>
<td>Model</td>
<td><input type='text' name='model' /></td>
</tr>
<tr>
<td>Unit Type</td>
<td>
<select name='unitt'>
<option>Laptop</option>
<option>Computer</option>
<option>Tablet</option>
</select></td>
</tr>
<td></td>
<td>
<input type='hidden' name='action' value='create' />
<input type='submit' value='Save' />
<a href='index.php'>Back to index</a>
</td>
</tr>
</table>
</form>
</body>
</html>