Forum Moderators: coopster
switch(true) {
case empty($_POST['field']):
echo 'blah blah';
case empty($_POST['field2']):
echo 'blah blah';
}
... you get the idea. i use default to go to next page using header("Location:..."); but i cant use the posted variables from the previous page when i use header location. i dont really wanna put all the data into a session or cookie or anything, is there another way to validate fields and post to next page still?
Create two forms on the page one has all hidden fields with the same names. Have the first form submit to itself and due your validations and backend processes if passed.
set the variable
$formgood = 1;
Remove the header(Location:) php code
Have a second form with all hidden fields and set the value with the post from the first form. Then set the form action to whatever.
In this example use page.php.
There is an if statement that will do an automatic submit of your hidden fields at the bottom when $formgood = 1.
<form name="FormName" method="POST" action="page.php"
<input type="hidden" name="fieldname" value="<? echo $_POST["fieldname"];?>">
</form>
<script type="text/javascript" language="JavaScript">
<!--
<?
if($formgood = 1)
{
echo "document.FormName.submit();";
?>
//--></script>