How to retain values of form fields after a page loads?

Discussion in 'PHP' started by gio, Jan 26, 2010.

  1. #1
    Is there a way to retain values of textfield/textbox when a user submits a form? i only want to retain values with errors or values I specify.

    For example i am posting to 10 blogs and 1-9 gets posted succesfully so I only want to retain the value from 10 when a page load after form submission. Can I do that? how?
     
    gio, Jan 26, 2010 IP
  2. prasanthmj

    prasanthmj Member

    Messages:
    62
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    45
    #2
    Are you asking how to programatically load the last submission from a user in your own form
    or
    how to keep last submission for your browser locally?

    For the first one, you can use PHP sessions.

    for the second one, look for Robo Form
     
    prasanthmj, Jan 26, 2010 IP
  3. Sky AK47

    Sky AK47 Member

    Messages:
    298
    Likes Received:
    8
    Best Answers:
    1
    Trophy Points:
    45
    #3
    Simply give the input the value of the POST variable.
    so like;
    <input type="text" value="<? echo $_POST['hi']; ?>" />
    Code (markup):
    if that's what you meant...
     
    Sky AK47, Jan 27, 2010 IP
  4. Kaizoku

    Kaizoku Well-Known Member

    Messages:
    1,261
    Likes Received:
    20
    Best Answers:
    1
    Trophy Points:
    105
    #4
    You can also use $_SESSION
     
    Kaizoku, Jan 27, 2010 IP
  5. gio

    gio Well-Known Member

    Messages:
    2,390
    Likes Received:
    162
    Best Answers:
    0
    Trophy Points:
    195
    #5
    Yes but i only want to retain values with errors.
    Thanks kaizoku! i made it work using session. :)
     
    gio, Jan 27, 2010 IP