What options are available to send an error message back to the form page?
I have a form on login.php it submits to process.php. process.php handles the db connection, validation etc. If there is an error, I want to pass that back to index.php.
ie:
} else {
session_destroy();
header("Location: /login");
$error = "Sorry, that user name or password is incorrect. Please try again.";
}
Since these are two different files, what are the best options available to set and retrieve the errors? $_POST, $_GET, $_SESSION?
For your specific case, and with the code given,
$_SESSIONis your best bet. I.e:Then back in index.php you’d have to check that session variable somehow, e.g: