I'm working on a script for forms that submits the data to itself to check for errors, if there are no errors it uses header() to send them to the next page. Is there a way I can send the $_POST data to the next page as well without the form being re-submitted?
<?php
if (isset($_POST['submit'])) {
$errors = array();
$moo = array();
if (empty($_POST['a'])) {
$errors[] = 'You forgot to answer Question 1!<br/>';
} else {
$moo = $_POST['a'];
}
if (empty($_POST['b'])) {
$errors[] = 'You forgot to answer Question 2!<br/>';
}
if (empty($_POST['c'])) {
$errors[] = 'You forgot to answer Question 3!<br/>';
}
if (empty($errors)) {
$_POST['aids'] = "RAWR";
$url = "http://localhost/test/test.php?page=2";
header("Location: $url");
exit();
} else {
foreach ($errors as $error) {
echo $error;
}
}
}
echo "
<form action=\"test.php?page=1\" method=\"post\">
<input type=\"text\" name=\"a\" value=\"" . $_POST['a'] . "\">
<input type=\"text\" name=\"b\" value=\"" . $_POST['b'] . "\">
<input type=\"text\" name=\"c\" value=\"" . $_POST['c'] . "\">
<input type=\"submit\" name=\"submit\">
</form>
";
?>