I am trying to redirect users to a custom error page (for example: error.php) when a duplicate entry is made, this is a sample of the insert statement, but I don’t know how to do the redirecting.
$values = $_POST;
foreach ($values as &$value) {
$value = mysql_real_escape_string($value);
}
$sql1="INSERT INTO loan (loan_id)
VALUES ('$values[loan_id]')";
$result = mysql_query($sql1);
if (!$result) {
die('Invalid query: ' . mysql_error());
}
The proper way to redirect form input is using the HTTP 303 redirect.
To redirect at the current line, do so something like this, in PHP:
You must ensure that you include the header function before any output.
Here it is in your code: