如何在重定向的php文件中输出新表单?

I am trying to pass variables buy echoing new forms after using header("Location: location.php"). So when it is redirected, it outputs the form in the redirectred php file.

<?php

header("Location: location");
echo "<form><input type = 'submit' value ='try again' > </form>";
//expected output:the form outputs in the same files
?>

Using header("Location:page") immediately exits your script and redirects the user to that page. However, I have successfully accomplished something very similar (to what I think you want) by scripting a Website Registration API.

In total, I wrote 3 critical scripts, plus the original form page, in/out functions, and an assortment of data storage modules to create a seamless process. Your needs might not be as complicated as mine, but I found this to be much more involved than a simple 'validation check'.

Basic outline:

  1. page original form is on: submit sends form data to script
  2. script parses incoming data and determines action
    • each input variable is parsed
      • if form data is empty: user is sent to original (blank) form page
      • if form data flags bad input: the form is reprinted (errors in red)
      • if form data is legit: data is stored; script advances to user portal
  3. login/logoff functions

Try to solve your problem by thinking about each step of the process and breaking it down into bite-size pieces. (first you have to see the input, then you have to check the input, etc.)

After the header("Location:url"); no other command will be executed but you can used document.getElementById("myForm").submit();

<form id="form" action="/url"><input type = 'submit' value ='try again' > </form>";
//expected output:the form outputs in the same files
<script>
  document.getElementById("form").submit();

</script>

or used curl