简体   繁体   中英

Php $_GET value is coming from another page, but i cant put that $_GET['id'] on the same page after submitting the from

After submitting the form the $_GET value which is the id of post it dissappear. How can i put this event after submitting... with all values of form too..

You can use hidden fields to send additional values with form submit . Like this:

<form action="myOtherFile.php" method="GET">
  <!-- put it anywhere inside the form and give it a desired name and value -->
  <input type="hidden" name="postId" value="PutValueHere" />    

  <!-- and the rest of the form -->
  <input type="text" name="address" value="" />
  <!-- and so on ... -->
  <input type="submit" value="Submit me" />
</form>

In the receiving PHP file you would then get the variable like this:

if(isset($_GET['postId']))
{
    echo "ID is: ".$_GET['postId'];
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM