Hi there guys,

I'm working on a form that on the initial page load asks for the information. On that submit, it goes to a validating page where they're asked to fix any problems. Then on the final submission, the form is processed.

My question is this:

I'm using the same page with different cases to do this, so:

form.php > form.php?action=verify > form.php?action=submit

If the values aren't being modified during the verification process(meaning they didn't need to be fixed), do I have to do anything at all to get them to carry over to the next page load?

I have 20 variables, 3 of which needed some fixing. I just want to make sure that:

1) the data not being modified during the verification process carries over
2) It can't be mishandled along the way

thanks,
json

    schwim wrote:

    If the values aren't being modified during the verification process(meaning they didn't need to be fixed), do I have to do anything at all to get them to carry over to the next page load?

    If the verification process involves redisplaying the form to the user and having them resubmit it, then no; all the information that you put into the form is resubmitted back to you (modulo any changes the user made).

    1) the data not being modified during the verification process carries over

    That's the whole point though; the user has the opportunity to modify the content of the form submission.

    2) It can't be mishandled along the way

    Of course, the user might make a mistake second time around, too.

      Hi there Weedpacket, and thanks very much for the reply.

      Due to the incredible size of the form(it's an employment application), I'm not showing them the whole form during the verification. If something fails(an unset value, email address fails check, empty text box), it will show them that question only. The rest aren't getting shown.

      Do I need to do a hidden value if it's not being shown to the user again inside the form, or will the values carry on to the next function?

      thanks,
      json

        Just put all the data into session variables. They'll remain sitting on the server for you to look at on later pages.

        Hidden form fields are not a good idea; it leaves the data entirely at the mercy of the user.

          Hi there Weedpacket. I know this is going to speak volumes of my ignorance, but I have to ask:

          Is creating a session sufficient for turning the variables into session variables, or do I have to do something besides creating a session?

          thanks,
          json

            First you have to start a session: [man]session_start/man.

            Then you have to store data in the session (via the $_SESSION supergloba, for example; more info on that can be found here: [man]variables.predefined[/man]).

            Coding examples can be found on the manual page for [man]session_start/man.

            A quick note about sessions: if you ever write data to a session and then immediately issue a header('Location: ...') redirect, sometimes the new data isn't written properly before the subsequent page accesses and loads the session data. In such cases, you might need to call [man]session_write_close/man before you issue the header() redirect.

              Hi there Brad,

              So from the manuals, is this the way I should do it?

              Create a session on form.php

              form.php submits to form.php?action=verify

              $name_first = strip_tags (mysql_real_escape_string (strip_mq_gpc (substr ($_POST['name_first'], 0, 40))));

              Then in the next page, $name_first would be called by:

              $name_first = ($_SESSION['name_first']);

              unless my data was modified for that value, in which case I would use:

              $name_first = ($_POST['name_first']);

              Is that what I should be doing, or did I miss the point of the manual completely?

              thanks,
              json

                Don't forget that you first have to store the POST'ed variable into the session:

                $name_first = strip_tags (mysql_real_escape_string (strip_mq_gpc (substr ($_POST['name_first'], 0, 40))));
                $_SESSION['name_first'] = $name_first;

                  Hi there guys,

                  Well, I've created such a convoluted mess, that I believe that I could win an award for incompetent coder of the decade or something.

                  First, my intention:

                  I wanted the user to submit the form. I wanted a verification process that would check certain fields and stop the user for correction. After the required fields were fixed, it would then allow the user to submit.

                  My problem: I have created an endless loop. If I fix one value, upon submission, a value that I fixed earlier is forgotten and the submission code shows back up again as if it was never fixed. I know that it's because of a situation I'm not checking for, but to be honest, my code seems so nasty, that I'm sure this can't possibly be the way I'm supposed to be doing this.

                  What I tried:

                  I tried to switch the POST values to SESSION values if they didn't need to be modified, then attempted to fix the required values, and move them to SESSION values only when the user successfully input the data.

                  What I need to do:

                  I need to be able to store the data once it's correct and make the script understand that it doesn't need to be checked anymore once it's been submitted correctly once.

                  Here's my code:

                  txt file

                  Here's the actual page(leave the radio boxes unchecked to see my problem).
                  script
                  Check "I agree" to get the submit button.

                  Aside from giving everyone a good laugh, I hope someone can help me figure out how to write a competent verification process.

                  thanks,
                  json

                    Write a Reply...