tags:

views:

33

answers:

3

i'm using a php page and it gets refreshed(on submit) . i need to keep the value of a textfield from a previous submission. how to make it

A: 

If you're just posting data back to the same script that displays the form, just do something like:

<input type="text" name="foo" value="<?PHP echo $_POST['foo']; ?>"/>

If your user is going to go "away", and then come back to the page, you probably can get away with stuffing the stuff you want to save in $_SESSION.

timdev
A: 

yes, the above thing is correct. Eventually use AJAX so eventually you need not to refresh the page and data will be preserved.

santosh
A: 

tim is right, but you'll have to be careful about escaping user input. Ideally what you want displayed is exactly what the user types in. You'll probably find that html entities such as &#39; will get converted.

Slightly better:

<input type="text" name="foo" value="<?PHP echo htmlentities($_POST['foo']); ?>"/>
Jonathan Swift