digihoo wrote:
i am validating form data, but when i redirect the user back to the
form page to correct the errors, all of the data they entered has
disappeared.
The browser only displays what you send.
If you want to send the same data a user submitted, you have to save it
between the form processing script and the script that outputs that
form. I'd do that with session variables:
<?php // form processing script
session_start();
if (isset($_POST['userdata']) {
validate_data($_POST); // define according to your needs
$_SESSION['userdata'] = $_POST['userdata'];
}
header('Location: form_output.php');
exit('Redirected <a href="form_output.php">here</a>.');
?>
and
<?php // form output script
session_start();
if (isset($_SESSION['userdata']) {
$useradata = $_SESSION['userdata'];
} else {
$userdata = ''; // or some other default value
}
?>
<form method="post" action="form_process.php">
<input type="text" name="userdata" value="<?php echo $userdata; ?>" />
<input type="submit">
</form>
Happy Coding :-)
--
I have a spam filter working.
To mail me include "urkxvq" (with or without the quotes)
in the subject line, or your mail will be ruthlessly discarded.