php - enable user to start form the last saved page -


I have 5 pages with a PHP form and I give users the possibility to start filling the form with my last saved Page you would like (Data should be saved in Db per page and if for any reason the user could not complete all the pages, he would be able to re-fill all the pages again). This is the stage I am trying to:

  1. Save user data per page, so that when he clicks on the "Save and Continue" button at the end of the page, Then all data will be saved in DB (this part is fine, I have already taken this step)

  2. When the user enters successfully, Check whether the user has already entered some data (each page I have some mandatory questions, so I check whether they are empty in DB, for example: "q6" field is required in page 1 and if this field (column q6) in db is not empty " "This means that the user has already responded to the first page and should be able to start from the second page. Then I will check another mandatory field in the next page such as q12, if the table In the "q12" column is not empty, it means that user also responds to the second page and can start from page 3, and so on ...

    Here's a part of the code: (To reduce the code, I just copied the situation to check that the user responded to the first page and i o to check the empty field in the next pages For other situations, press

      // if the user name is Amp; Password found in DB, successful $ _SESSION ['SESS_MEMBER_ID'] = $ result- & gt; Mem_id; $ _SESSION ['SESS_USERNAME'] = $ result- & gt; User name; $ _SESSION ['SESS_LAST_NAME'] = $ result- & gt; password; $ Result = $ conn- & gt; Prepare ('SELECT * FROM is the answer where user name =: username'); $ Result-> Execute (array (': user name' = & gt; $ username)); $ Line = $ result- & gt; Obtain (PDO :: FETCH_OBJ); If (empty ($ row-> q6)) // If the user has not responded to q6 (which requires first page submission and go to page 2 {$ stmt2 = $ conn- & gt; ('INSERT (Answer:' Username '= & gt; $ username));} Hold (PDO exempt $ E) {resonance' error: '$ E (Answer: username) value (user name)'); $ Stmt2- & gt; - & gt; GetMessage ();} header ("location: home.php"); // Homepoints where users can click on the link to start filling out the form in the page 1.php exit ();} and {// If the q6 database already has an answer, this means that the user is already filled Has been done and saved the first page, so it should be able to continue the second page header ("location: page2.php"); Exit ();}} else {// login $ errmsg_arr [] = 'username and password not found'; $ Errflag = true; If ($ errflag) {$ _SESSION ['ERRMSG_ARR'] = $ errmsg_arr; Header ("location: index.php"); / * Exit (); * /}}   

    The problem:

    This works perfectly for the user who is flooding the form for the first time (his username is entered The table "Answer" when it will be redirected to L. Ogins and home.php, where it can get a link to start filling out the form (page 1.php), but the problem is that for example if he fills the first page If so, click on "Save and Continue" again on the second page Desired and if it comes out of the form (as if it accidentally closes the window), and then log in again, it will be redirected to page1.php of insead page2.php

    Can someone please help me with the problem of this code?

    Thank you,

    In page 1.php you can check in the database whether the information is already filled by the user, And if so, you can redirect it to page 2.ph. Similarly, in page 2, page 3, page 4.php

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -