Jump to content

Issues with recalling form data...

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
3 replies to this topic

#1
shackrock

shackrock

    Learning Programmer

  • Members
  • PipPipPip
  • 66 posts
Alright, I am having a horrible time here trying to find the issue in a simple signup form that gets emailed to me after signup...

The form works fine, however the form data will not "save" itself in the case that there is an error. Let me show you:

<link-removed> - this is the form that, if you make an error, the form will not submit (correctly), but all the form fields are now missing.

<link-removed> - this is a smaller contact form. I did nothing different here in making this form, but in this contact form the data has no issue getting recalled if you make an error.


Are there "common mistakes" I might be making? I've compared the two forms 1000 times.... if anyone can offer to help please let me know...

Thanks!

Edited by John, 18 January 2012 - 10:35 AM.


#2
brutetal

brutetal

    Newbie

  • Members
  • Pip
  • 6 posts
It would be helpful if you posted the code for it.

#3
Alexander

Alexander

    It's Science!

  • Moderators
  • 4,124 posts
The browser (Most likely Firefox because it's forgiving) will cache certain text fields. If you make a mistake and you don't hit "Back", it will just contain uninitialized forms, such as a new page.

Why not store what the inputted form into the session? You can do many many things with the POST objects and place them in $_SESSION, and when they make an error it'll check and initialize, here's an example:

if(isset($_SESSION['formdata_name'])) {
   print '<input type="text" name="form_name" value="' . $_SESSION['formdata_name'] . '"/>';
} else {
   print '<input type="text" name="form_name"  value="Enter your name here!"/>';
}
This would allow the person to see the form data if you just redirect them back because of an error.

#4
Nastya

Nastya

    Newbie

  • Members
  • Pip
  • 1 posts
I consider your problem consists of uncorrect estableshment of inputing fields. Did you use for it form builder as an additional function of php form?