The correct way to redirect form input is using HTTP 303 redirection .
To redirect in the current line, do it like this in PHP:
header('Location: /error.php', TRUE, 303);
die('Input error.');
You must ensure that the header function is enabled before any output.
Here it is in your code:
if (!$result) {
header('Location: /error.php', TRUE, 303);
die('Invalid query: ' . mysql_error());
} else {
header('Location: /success.php', TRUE, 303);
die('Success');
}
source
share