Forum Moderators: coopster

Message Too Old, No Replies

Retaining contents of HTML forms

Submit HTML forms

         

DNice

9:16 am on Feb 19, 2007 (gmt 0)

10+ Year Member



Hello fellows!

I'm new in the forum and coding with PHP and MySQL. I'm using HTML forms an get the items in the form to be validated by a PHP script.If i encounter an error in the form i use a PHP include() function to re call the HTML form.

I want to put back the values in the text boxes where there are no errors.How do i do that?

cameraman

9:29 am on Feb 19, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Welcome to WebmasterWorld DNice!

In the form, you specify values fed by php variables:
<input type="text" name="address" id="address" value="<?php echo $address;?>" />

Don't forget to define the variables (likely empty: $address = ''; ) on first display of the form so you don't generate errors.
If you subsequently redisplay the form you set the variables to the posted values instead of blanks or defaults. If you have a textarea, the value gets placed between the beginning and ending tags.

DNice

10:20 am on Feb 19, 2007 (gmt 0)

10+ Year Member



Thanks cameraman.

That's exactly what i was looking for.