PHP:如何在使用提交按钮将用户引导到另一个页面时将隐藏变量传递到一个页面?

I am looking to get the string variable to go to one page, new user page, while the user is directed to page 8.

</p>
<form method="GET" action="pg8.php">
<! moving variables to text file-->
<input name="input1" type="hidden" <?php echo "value=$i1" ?> >
<input name="submit1" type="hidden" <?php echo "value=$f"?> >
<input name="submit2" type="hidden" <?php echo "value=$t"?> >
<input name="submit3" type="hidden" <?php echo "value=$fa"?> >
<input name="submit4" type="hidden" <?php echo "value=$c"?> >
<input type="submit" name="submituser" value="continue">

<?php $string="$string.{$i1}.{$f}.{$t}.{$fa}.{$c}";?>
<input type="hidden" name="newuser" value=<?php echo "$string" ?> >
</form>

Use javascript for that. On submit, send data via ajax to first page. Instantly after that refer via window.location=secondpage.php to second page.

Why not use a redirect on the first stop to send the user to page 8 after you've dealt with the form?

You could accomplish this with header().

one_page.php

// deal with the form
$_GET['some_field'];

// after you're done, send the user to page 8
header('Location: pg8.php');
exit(); // to prevent from executing anything else before the redirect

And in the form, just change

<form method="GET" action="one_page.php">

This would yield the best result IMO.

Scheme of redirects

  1. The user fills out a form on form.php and clicks the submit button
  2. Then the user is sent to what the form action is, say form_logic.php
  3. Inside form_logic.php after some calculations, the user is sent off to the final page of this form submission, say form_result.php

This all happens very quickly and from the users perspective (depending on the amount of work you do in form_logic.php) it appears that he was sent directly to form_result.php.