|
Posted by Tyno Gendo on 09/14/07 13:57
Albert Ahtenberg wrote:
> Hello,
>
> I have two questions.
>
> 1. When the user presses the back button and returns to a form he filled
> the form is reseted. How do I leave there the values he inserted?
I always capture the values into a session and when the form is created
I echo the session values into the value="" section, or whatever is
needed, different in the case of checkboxes etc., have to mark as
selected="selected" etc.
You could use normal cookies too if you don't want to start a server
session.
> 2. When the user comes back to a page where he had a submitted POST data
> the browser keeps telling that the data has expired and asks if repost. How
> to avoid that? I tried registering all POST and GET vars as SESSION vars but
> it also has its disadvantages...
I usually use a header redirect back to forms when data is invalid or
when a succesful submission is made, I use a session var 'messages' to
hold any messages to print at the top of the form
eg.
$_SESSION['messages'] = 'Your submission was invalid';
exit(header("Location: {$_SERVER['PHP_SELF'}"));
Navigation:
[Reply to this message]
|