Dear all,

Actually i posted before, but nobody replied, may b i asked the question wrongly.

Page A post data from form 1 to form 2 on Page B.

Page B has 2 buttons, one to submit to page C and one to go back to page A.

Once they click on button to go to page A, the previous data they entered should appear. Previously i used hidden variables, and the data appeared. Now since i have more than 100 fields, i'm unable to do so.

I've read abt $HTTP_POST_VARS and $_POST and tried to use it be in vain. Please help me out.

Here's how i try to retrieve the data on Page A

$address=stripslashes($HTTP_POST_VARS['address']);

<input type="text" name="address" maxlength="120" size="40" style="width:300px" value="<?=$address?>">

the value is empty! can some1 please help me out.

I even tried printing posted variables as follows:

while(list($pkey, $pvalue)=each($_POST))
echo $pkey." = ".$pvalue."<br>";

but still no value =(

please help out thx.

    i have had problems getting the

    <?= $variable; ?> to work

    i always use

    <? echo $variable; ?>

    may not be your problem, but that is all that i can see that i don't do and have had problems with in the past

    <input type="text" name="address" maxlength="120" size="40" style="width:300px" value="<?=$address?>">

      Could you post more of your script?

      I assume your form begins with:

      <form method=POST action="pageb.php">

      ?

      Ah yes, and as mentioned <?=$address?> is short tags notation which is not really a good idea.

        Hi,

        Thx for the quick reply.

        Ok here more of my code.

        Page A: user_form1.php:

        the php script is :

        $address=stripslashes($HTTP_POST_VARS['address']);

        and my html codes are:

        <form name="form1" method=post action="user_from2.php">
        <table width="470" border="0" cellspacing="0" cellpadding="0" valign="top">
        <tr>
        <td>&nbsp;</td>
        </tr>
        <tr>
        <td align=right>address:</td>
        <input type="text" name="address" maxlength="120" size="40" style="width:300px" value="<?=$address?>">
        </td>
        </tr>
        <tr align="center">
        <td>
        <input type="image" border="0" name="imageField" src="nextbutton.gif" width="60" height="19" onClick="document.form1.submit();" alt="next &gt;&gt;">
        </td>
        </tr>
        </table>
        </form>

        The new page contains another form with the 2 buttons:

        <script language="javascript">
        function goBack()
        {
        document.form2.action="user_form1.php";
        document.form2.submit();
        }
        </script>
        <form name="form2" method=post action="user_from3.php">
        <table width="470" border="0" cellspacing="0" cellpadding="0" valign="top">
        <tr>
        <td>&nbsp;</td>
        </tr>
        <tr>
        <td align=right>email:</td>
        <input type="text" name="email" maxlength="120" size="40" style="width:300px" value="<?=$email?>">
        </td>
        </tr>
        <tr align="center">
        <td>
        <input type="image" border="0" name="imageField2" src="backbutton.gif" width="60" height="19" onClick="onClick=goBack();" alt="&lt;&lt; back">
        <input type="image" border="0" name="imageField" src="nextbutton.gif" width="60" height="19" onClick="document.form1.submit();" alt="next &gt;&gt;">
        </td>
        </tr>
        </table>
        </form>

        please help.

        thx

        Originally posted by feldon23
        Could you post more of your script?

        I assume your form begins with:

        <form method=POST action="pageb.php">

        ?

        Ah yes, and as mentioned <?=$address?> is short tags notation which is not really a good idea.

          did you try taking out the <?= and replace with <? echo

            Hi.

            First of all use $_POST, since $HTTP_POST_VARS is deprecated.

            I don't have much time to analyze your problem now, but here's how I'd do it:

            foreach($_POST as $k => $val)
            {
            stripslashes($val);
            $$k = $val;
            }

            After doing this each field of the form will be a var, so instead of using:

            echo $_POST{'foo'};

            You'll use

            echo $foo;

            hope it helps

              hi,

              Yeps i did, but still nothing.

              i used the following codes to print the variables:

              while(list($pkey, $pvalue)=each($_POST))
              echo $pkey." = ".$pvalue."<br>";

              or

              while (list($lvar, $lvalue) = each($HTTP_POST_VARS))
              echo $lvar." = ".$lvalue."<br>";

              "address" doesn't get printed at all, while email did.

              Does it mean that i need to post address as a hidden variable? If i have to, doesn't tht make the use of $HTTP_POST_VARS redundant?

              please advice 🙁

              Originally posted by stolzyboy
              did you try taking out the <?= and replace with <? echo

                HI, thx for the tips.

                I added tht piece of code in the my user_form1.php as follows:

                foreach($_POST as $k=>$val)
                {
                $$k = $val;
                echo ${$k};
                }

                It actually printed the values passed from user_form2.php, that is "email", but not the original "address" value 🙁

                please help 🙁

                thx

                Originally posted by lobobr
                Hi.

                First of all use $_POST, since $HTTP_POST_VARS is deprecated.

                I don't have much time to analyze your problem now, but here's how I'd do it:

                foreach($_POST as $k => $val)
                {
                stripslashes($val);
                $$k = $val;
                }

                After doing this each field of the form will be a var, so instead of using:

                echo $_POST{'foo'};

                You'll use

                echo $foo;

                hope it helps

                  $_POST and $HTTP_POST_VARS are not maintained through more than page. If you have a form with an address input on it, which posts to a form with an email input but not address input, then post that second form to a third, the value of 'address' will be lost. You need to add:

                  <input type=hidden name="address" value="<?php echo $_POST['address'];?>">

                  to user_form2.php, inside the <FORM> tag somewhere.

                  hth

                  -Jim Keller
                  http://www.centerfuse.net

                    People don't realize that very often, you can handle a form, the confirmation of entries on that form, and the "thank you" notice for that form all in a single PHP document.

                    <?php
                    $submit=$_POST['submit'];
                    $name=$_POST['name'];
                    $email=$_POST['email'];
                    $address=$_POST['address'];
                    $php_self=$_SERVER['PHP_SELF'];
                    
                    if (!isset($submit)) {
                    ?>
                    
                    <form method=post action="<?php echo $php_self; ?>">
                    <!-- display form -->
                    
                    <?php
                    } else {
                            if ((!isset($name)) or (!isset($email)) or (!isset($address))) {
                            echo "You have not filled out the form completely.
                            Please click the BACK button in your web browser
                            to return to the form.";
                            } else {
                    
                        // process form data and write it to the server or whatever
                        // else you want to do with it.
                    
                        }
                    }
                    ?>

                      yes, that is why it is frustrating sometimes trying to check out other peoples code when they are bouncing from page to page, i have some sites that rely on one page of 1000 or more lines of code, and that is relatively small for php to handle, as long as you are efficient in creating the pages, it should be no problem doing this

                        Try Startin a session so that the systemn keeps track of your variables (first line of code).

                        <?session_start()?>

                          Maybe it is silly what I say, but computer is not to much intelligent to know that if you write "user_from2.php" you think "user_form2.php" :-)

                          The same with "user_from3.php"

                          Gregor63

                            Write a Reply...