SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    Ribbit... Eric.Coleman's Avatar
    Join Date
    Jun 2001
    Location
    In your basement
    Posts
    1,268
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Forms, PHP, Not Cachin'

    Has anyone had trouble with forms, where it won't retain data when you hit your browsers back button?

    My Example,

    I have a form, people fill in the information. If something is left blank, it gives an error, and tells them to go back and fill in the form. When they hit the back button, the form is empty again... Why?

    Thanks,
    Eric
    Eric Coleman
    We're consentratin' on fallin' apart
    We were contenders, now throwin' the fight
    I just wanna believe, I just wanna believe in us

  2. #2
    purple monkey dishwasher scoates's Avatar
    Join Date
    Nov 2001
    Location
    Montreal
    Posts
    794
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

  3. #3
    Action! filmfoto's Avatar
    Join Date
    Dec 2001
    Location
    Sweden
    Posts
    278
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    A solution:
    • Error check the posted form.
    • On error notify the user and redisplay the form with the relevent variables.


    That way the user doesn't have to use the back button.



    Cheers!

  4. #4
    Ribbit... Eric.Coleman's Avatar
    Join Date
    Jun 2001
    Location
    In your basement
    Posts
    1,268
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I do error check the forms.. no sessions invloded.. there just blank when you go back..
    Eric Coleman
    We're consentratin' on fallin' apart
    We were contenders, now throwin' the fight
    I just wanna believe, I just wanna believe in us

  5. #5
    purple monkey dishwasher scoates's Avatar
    Join Date
    Nov 2001
    Location
    Montreal
    Posts
    794
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hmm.. I see what you're saying..
    It's happening to me to.
    One solution, as filmfoto pointed out is to store the data in a session, and pull it back out when displaying the form.. clunky, though..

    S

  6. #6
    Action! filmfoto's Avatar
    Join Date
    Dec 2001
    Location
    Sweden
    Posts
    278
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Actually you don't need to store the data in session variables. The form varibles are all available through $HTTP_POST_VARS. If I find an error when error checking I redisplay the form instead of the content that would have appeared if the form checking had passed. That way the user gets direct feedback what is wrong with his post.

  7. #7
    purple monkey dishwasher scoates's Avatar
    Join Date
    Nov 2001
    Location
    Montreal
    Posts
    794
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    unless your form isn't posting to itself...

    I usually have a separate processor with each form.. then you need to pass the variables back to the form, from the processor..

    I suppose serialize() would be useful for this.

    S

  8. #8
    Ribbit... Eric.Coleman's Avatar
    Join Date
    Jun 2001
    Location
    In your basement
    Posts
    1,268
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I use a seperate thing to handle my forms as well...

    One thing, I thought might have been causing it, I had this function, that on error, would display there message, it kinda looked like:

    PHP Code:
    function crapout($text) {
         echo 
    $text;
         exit;

    This is not just the function itself.. there is alot of formatting, storin' of error's involded, but that is the basis..

    So, i disabled the function, and it still doesn't send values back...
    Eric Coleman
    We're consentratin' on fallin' apart
    We were contenders, now throwin' the fight
    I just wanna believe, I just wanna believe in us


Bookmarks

Posting Permissions

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