Jump to content

PEAR quickform - save form state on reload?


dijona

Recommended Posts

I'm wondering if anyone has any tips for saving a form state on reload? I know it can be done with JavaScript and cookies but I've got a hierselect element (2nd dropdown is dependent on selection from 1st dropdown) that seems to throw a wrench in things. Is there something built into quickform? anyone done something like this?

Link to comment
Share on other sites

Well that's not actually that helpful. I know I'm a noob and all but...

 

Well, i've managed to work out a few things, but I'm still stuck.

 

Ok, here's the thing. I've got the form in PHP. some of the values are pre-populated text fields that use session variables and variables to hold the content. i.e. (PHP is just jotted down as an example..i know there are errors)

 

snip...

$myMSG = $_SESSION['Book']." ".$_SESSION['Chapter'];

echo "<form...>";
(form stuff...)

echo"<textarea name='message'>$myMSG</textarea>";
etc...
<input type=\"submit\" value=\"Send Message\">
echo "</form>";

 

I've got some basic error-checking that validates the form. If it fails, It prompts the user to enter the missing/incorrect data. The problem is - when the form reloads, $myMSG is gone.

 

So is this because my session data is being deleted on the submit? Is there any way I can have the form reload and still keep the value in $myMSG?

 

thanks in advance!

Link to comment
Share on other sites

yes, as I said it's just a snippet of code.

 

the form displays fine with all the session variables - it's only when form validation fails (i.e. user didn't enter the email-to: field) and the form reloads that the session variables are lost.

Link to comment
Share on other sites

well I'm travelling so I don't have the whole code. I really thought the sample would be more than sufficient to let people know basically what's going on. The basic question, again, is: If I populate a form field with a session variable - submit the page - everything works great. BUT, if the form fails validation and reloads so user can enter/correct data - why does the field containing the session variable data disappear, and what can I do about it?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.