need help with form validation

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
EXDev
Forum Newbie
Posts: 7
Joined: Sun Feb 23, 2003 9:05 am

need help with form validation

Post by EXDev »

Hi,

i have a html form, and use php to validate the inputs. Basically the validate.php validate the input, if all inputs are good, it will call header("location:anewpage.php") to open a new page. if any input is invalid, it will call header("location:userinput.html") to go back to the form.
my problem is when there are invalid inputs, it will go back to the user form, but all the input values are gone, its like hitting refresh button.
how can i keep all the values when it returns to the form page?

Thanks
McGruff
DevNet Master
Posts: 2893
Joined: Thu Jan 30, 2003 8:26 pm
Location: Glasgow, Scotland

Post by McGruff »

Set an initial value for the form fields. For example, if you've included an html template, add:

value="<?php echo $var; ?>"

If you did the form in php (or eval'd a html template), leave out the php tags and the echo, ie just insert the var.

The vars have to be declared in the script that calls the form before the form is built.
Post Reply