Results 1 to 4 of 4

Thread: Remember if a form has been filled in

  1. #1
    Join Date
    Dec 2006
    Posts
    34
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Remember if a form has been filled in

    I've never written cookies and am presuming that this is the way to solve my problem.

    I have a page with a lot of information on it. What I am wanting to do is cut down on the amout of information first given and have a form to get the rest of the information. Once the form is completed and the submit button pressed the same page is loaded but without the form and displaying the extra information. I know how to do this via php so that is no problem.

    The problem is that if someone has previously filled out the form to view the extra information and then come back to the same at a later date. Obviously I do not want to be requesting that they give their details again. So how can I set it up so that it checks to see if they have filled out the form, if not then the form shows, if they have then the extra information shows?

  2. #2
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    Well, you could use cookies (using Javascript or PHP). Another option (and a better idea I feel), would be to use a database. Cookies would probably be your best bet (unless the user deletes their cookies or the browser does not accept them).

    Simple example (using PHP):

    When the form gets submitted, it sends the info to a PHP script. Then, in that script (somewhere), it has this:

    Code:
    setcookie('CookieName', 'Data', time()+3600);
    Then, to see if the form has already been saved, at the top of the form script, place this:

    Code:
    if ($_COOKIE['CookieName'] != "") {
    donotShowForm();
    }
    
    else {
    showTheForm();
    }
    (Of course, made up functions but you get the idea).

    Hope this helps.
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

  3. #3
    Join Date
    Mar 2007
    Posts
    23
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by thetestingsite View Post
    Well, you could use cookies (using Javascript or PHP). Another option (and a better idea I feel), would be to use a database. Cookies would probably be your best bet (unless the user deletes their cookies or the browser does not accept them).

    Simple example (using PHP):

    When the form gets submitted, it sends the info to a PHP script. Then, in that script (somewhere), it has this:

    Code:
    setcookie('CookieName', 'Data', time()+3600);
    Then, to see if the form has already been saved, at the top of the form script, place this:

    Code:
    if ($_COOKIE['CookieName'] != "") {
    donotShowForm();
    }
    
    else {
    showTheForm();
    }
    (Of course, made up functions but you get the idea).

    Hope this helps.
    i have been trying to create something like this basicly the same concept as yours but to hide the form i have to use JS and i am googleing how to put JS code into php then sorted

  4. #4
    Join Date
    Mar 2007
    Posts
    23
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    javascript i am haveing no joy so i am just simply going to use php include and have 2 version of site, 1 with the form 1, without..

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
  •