Search code examples
phppostgetpython-requests

Send get data again to another page in php


In my website I have some url like

example.com/test/test?name=dd&type=a

I want to send data again to another page like:-

example.com/test/test/again?name=dd&type=a

How can I send data to /again from /test tell me please


Solution

  • You first need to store the data from get variables

    $name = $_GET['name'];
    $type = $_GET['type'];
    

    Now assuming you want to send this data to page2 on button click

    <form method="get" action="page2.php">
          <input type="hidden" name="name" value="<?php echo $name;?>">
          <input type="hidden" name="type" value="<?php echo $type;?>">
          <input type="submit">
    </form>
    

    Do the same for getting those variable at page2

    $name = $_GET['name'];
    $type = $_GET['type'];
    

    Hope this will help you!