Going back to edit a form

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
acs888
Forum Newbie
Posts: 2
Joined: Tue Aug 12, 2003 1:18 pm

Going back to edit a form

Post by acs888 »

i have created a form using php. when the user submits the form (for the first time) the form is 'parsed' and then displayed in a non-form page. the user has the chance to edit any errors or just send as-is. if the user has an error i tried using:

<input type="button" value="Edit" onclick=
"history.go(-1)">

this obviously takes the user back to the initial form page, however the form is reset. how do i 'save' or reload the form for the user to edit? thanks!
User avatar
JAM
DevNet Resident
Posts: 2101
Joined: Fri Aug 08, 2003 6:53 pm
Location: Sweden
Contact:

Post by JAM »

Code: Select all

<?php
    header("Cache-control: private");        
?>
On top of the page(s) might do the trick, but I'm getting nervous because another user here said that 'it depends' if it's this issue...

Other thoughts might be to;
Add the form's information in hidden-<input>'s aswell as in the non-form part of page.
Add another submitbutton with topic "Change" that resends the info from the hidden fields.
Once that is done, you have new info you can put back into the value="" areas in your form...

Geez, sounded messy...
User avatar
Seth_[php.pl]
Forum Commoner
Posts: 30
Joined: Sun Aug 10, 2003 5:25 am
Location: Warsaw / Poland

Post by Seth_[php.pl] »

Use sessions to store variables posted from form.

When you print form site check if there are session variables.
If exists some datas print them in value property of form item.
Instead of history.go(-1) use link to form.

That should solve problem.
acs888
Forum Newbie
Posts: 2
Joined: Tue Aug 12, 2003 1:18 pm

Post by acs888 »

thanks man,
<?php
header("Cache-control: private");
?>

did the trick!!
Post Reply