Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 12 of 12
  1. #1
    Senior Coder
    Join Date
    Jun 2002
    Location
    near Oswestry
    Posts
    4,508
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Forms reset on history back ... maybe session related

    I have this mailform where it does a simple "you haven't filled everything in" message and ask you to go back. But when I press back the form is empty.

    I'm starting a session on both pages, but I don't change any settings, only an ini directive to make it generate compliant argument separators. The mailform page also has "private" cache control, if that's relevant.

    Any ideas for what's happening, or what I can do about it?
    "Why bother with accessibility? ... Because deep down you know that the web is attractive to people who aren't exactly like you." - Joe Clark

  • #2
    Supreme Overlord Spookster's Avatar
    Join Date
    May 2002
    Location
    Marion, IA USA
    Posts
    6,278
    Thanks
    4
    Thanked 83 Times in 82 Posts
    I'll have to assume you are setting the values in the forms from the session properly since I do not see any code. Are you starting the session on each page? Can only speculate without seeing code.
    Spookster
    CodingForums Supreme Overlord
    All Hail Spookster

  • #3
    Senior Coder
    Join Date
    Jun 2002
    Location
    near Oswestry
    Posts
    4,508
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I'm not setting any form values from session data - all I use the session for is to check the validity of the POST request to the mailform.

    I'm really not sure how much of the code is relevant so here's a demo - http://af.brothercake.com/dropdown/contact/ - if you fill in your name but not email - it posts to another script (not part of that page) which then does header("Location: ..") to send you to the "missing" page. When you click "back" from that the name is gone.

    I can post all the PHP from the page, and the mailform script, if that would help you to help me ..?
    "Why bother with accessibility? ... Because deep down you know that the web is attractive to people who aren't exactly like you." - Joe Clark

  • #4
    Supreme Overlord Spookster's Avatar
    Join Date
    May 2002
    Location
    Marion, IA USA
    Posts
    6,278
    Thanks
    4
    Thanked 83 Times in 82 Posts
    Well for me the information stayed in the form when hitting the back button. This would be a browser setting issue.

    There are a few ways of effectively eliminating that problem though. The easiest way in my opinion is to submit to the same php file and do something like this:

    PHP Code:
    if(form submitted){
        if(
    form data is valid){
            
    process form and then redirect visitor
        
    }
        else{
            
    show form again with errors and populate using data from post array or data stored in session
        
    }
    }
    else{
        
    just show form

    The other way would be to submit to another page in which case it would probably be best to store the information in a session. Then just populate the original form with session data when they click the back button.
    Spookster
    CodingForums Supreme Overlord
    All Hail Spookster

  • #5
    Regular Coder
    Join Date
    Sep 2002
    Location
    British Columbia
    Posts
    235
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Don't require the user to use the back button. If they do not enter everything correctly, show the form again instead of telling them to go back, and have the form filled in with the POST data.

  • #6
    Senior Coder
    Join Date
    Jun 2002
    Location
    near Oswestry
    Posts
    4,508
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You're both absolutely right - I should be doing proper validation and re-presentation of empty fields.

    This is just a temporary solution, and if the problem is just me then I won't worry about it for now.

    Thanks
    "Why bother with accessibility? ... Because deep down you know that the web is attractive to people who aren't exactly like you." - Joe Clark

  • #7
    Senior Coder Nightfire's Avatar
    Join Date
    Jun 2002
    Posts
    4,265
    Thanks
    6
    Thanked 48 Times in 48 Posts
    It happens with me too BC, only solution I found was to show the form again.

  • #8
    Senior Coder
    Join Date
    Jun 2002
    Location
    near Oswestry
    Posts
    4,508
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Ah ... I'd better get on it then
    "Why bother with accessibility? ... Because deep down you know that the web is attractive to people who aren't exactly like you." - Joe Clark

  • #9
    New Coder
    Join Date
    Jan 2004
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi,

    This may be of some help.... if you make sure that the 'session.cache_limiter' value is set to 'private, must-revalidate' in the php.ini file it may solve your problem. I have noticed that the default php.ini config seems to prevent data in forms from showing when the user uses the browser back button.

    Anyway, this may not help you, but I thought I would share this just in case!!

    stuartc1
    -~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
    www.php-editors.com - PHP Editors Reviewed
    www.phphub.com - PHP Community Hub
    www.php-freelancers.com - PHP Freelance Jobs
    -~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~

  • #10
    Senior Coder
    Join Date
    Jun 2002
    Location
    near Oswestry
    Posts
    4,508
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Didn't seem to help, but thanks all the same. I think I'll repopulate it with session data until I have time to redo it properly.
    "Why bother with accessibility? ... Because deep down you know that the web is attractive to people who aren't exactly like you." - Joe Clark

  • #11
    New Coder
    Join Date
    Jul 2002
    Location
    Florida
    Posts
    60
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Show Form again?

    You mean redirect them back to the previous form, from the form that is doing the validation, or what? I'm not clear on this here.

    I've tried using session variables in this situation. But I ran into one little problem. If you provide a CLEAR (reset) button on the first form, the form simply refreshes itself with the session variable, and no clearing of the form can ever be done!

    Amusing maybe, but not to the user.

  • #12
    Senior Coder
    Join Date
    Jun 2002
    Location
    near Oswestry
    Posts
    4,508
    Thanks
    0
    Thanked 0 Times in 0 Posts
    No .. not useful at all ... could always intercept the event with javascript and write an empty string into each box ...

    .. but in fact - even though storing it in a session worked in development - it doesn't work on the live server anyway. Don't know why ... I've probably made a silly mistake somewhere ... to be honest I don't really have time for this

    I'm just gonna leave it and hope no-one has a problem, until I can implement proper validation.

    Ta
    "Why bother with accessibility? ... Because deep down you know that the web is attractive to people who aren't exactly like you." - Joe Clark


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •