I've written a form that performs form verification on the same page using

if(isset($_POST['submit'])) {

This works just fine. But then, once the form is verified, I need to pass the form data along to another page for processing (i.e., evaluating the data and saving it to a database).

The method I've used for this is to implode the $POST variable on the form page, and attach the resulting string to the location URL for the processing page, like so:

$post_string=implode(',', $_POST);
header("Location: $SECUREPATH/administration/users_process.php?p=" . $post_string . "\n\n");

And then explode the $GET variable string on the form processing page, and reassign the resulting values to their variable names, like so:

$post_array=explode(',', $_GET['p']);
$fname=$post_array[1];
$mname=$post_array[2];
etc.

This doesn't seem like a very efficient way of accomplishing this task of moving data from the form page to the processing page.

Is there a better way? Is there a way, for instance, to force the data already being held in the $_POST array to "repost" to the processing page without the user having to click on a submit button?

    if the page you are ultimately sending to is on the same server then use a [man]session[/man]. if not then read this.

      Thanks. That was much easier than I thought. I also discovered that because you can assign an array to a session variable, I could set up a single session variable and feed it the $POST array.

      $_SESSION['post_array']=$_POST;

      Probably a trick all experienced programmers are familiar with but it was nice discovery for me. Neat.

        Write a Reply...