Hi Guys, I am having a form with nearly 20 fields. some people only fills few details and navigate to previous page and once he arrived back they lost all the data they typed.How to store this ? what are the methods available to do this. But once they submitted all the details get cleared. Please advice me.
You can save their details in a session or a cookie and then echo them out. For example (with sessions), on the form handler script: session_start(); //This must be the first line for a session to work //Assign submtited post variables to session variables, which can be transferred from page to page $_SESSION['formName'] = $_POST['name']; $_SESSION['formAge'] = $_POST['age']; $_SESSION['formGender'] = $_POST['gender']; //etc for the 20 post variables PHP: Then on your form page: session_start(); //Again this needs to be the first line //Doctype <html> <head> ///Head </head> <body> <form action="handler.php" method="post"> <input type="text" name="name" value="<?php echo $_SESSION['formName'] ?>" /> <input type="text" name="age" value="<?php echo $_SESSION['formAge'] ?>" /> <input type="text" name="gender" value="<?php echo $_SESSION['formGender'] ?>" /> </form> </body></html> PHP:
Wd_2k6, I think your solution will not work, because on a back hit, the form is not posted yet and the post array will still be empty and therefore the session array will also be empty. My approach would be to write some ajax (javascript) to store the values of the fields to the session array on field exit, the session array will be filled accordingly then would be displayed the way Wd_2k6 explained.
Yes, it helps. Maybe you’ll have to research this further depending on what kind of fields you have on your form. Let me try to give you a hand, but you have to clean it to fit your needs. Example: If you have a text field named mytextfield, you can write the ajax using jquery code to update the $_session[‘mytextfield’] value every time your user types in a character. I know it is easier said than done, but at least you can start somewhere. Best luck
you can save your form by taking its screenshots and pasteing it on paint.It will take few seconds.If you have some doubts then keep on touch with me in DP ieill help you.
Hi , I dont like to grab the page and save it .What i need is entirely differnent in from your answer.