Click to See Complete Forum and Search --> : Inserting old values into new form after reloading


IanMartins
06-20-2008, 11:42 AM
I've made a form where the user can submit his name, email-address and a message. A javascript validates that all fields are filled out before the form is submitted. If it validates, PHP handles more thorough validation and sends the information to me in an email. What I'd like to learn next, is how to make the form remember all the values that the user has inserted, assuming any values makes it through the javascript validation, but are stopped by the PHP validation, making the page reload.

Can anyone point me in the right direction for this? I'm having a hard time finding any good examples to learn from. Thanks.

mainenotarynet
06-20-2008, 04:16 PM
try:
<input type="text" name="textbox1" size="25" maxlength="255" value'"<? if(isset($_POST['textbox1'])) echo $_POST['textbox1']; ?>" />

this will check if the form had been submitted before and place the value in the box if it is present

This code came from a book I have called PHP and MYSQL for dynamic Websites by Lartry Ullman

this should do what you need
Maine Notary Net

IanMartins
06-20-2008, 04:41 PM
Just what I was looking for -- thank you. :)

IanMartins
06-21-2008, 01:14 PM
Is there a way to apply this to <textarea>, which doesn't have a value attribute?

EDIT: Nevermind, the answer became obvious. ;-)