How to pass variable between two web pages with PHP without using session

I need to know How to pass variable between two web pages with PHP without using session , have a DIV link in which inside there is id i want to pass to another page when a link is clicked but i fail to do it. please help me:

firstpage.php ( where there is a link) :

   ......
 <?php

  $identity = $_POST['book_id'];
while($ResultsRow=mysql_fetch_array($res)) { 

    ?>  
<div class="col-md-2 offset-md-2">
   <div class='thumbnail'>
    <a href="shopping.php?<?php echo $identity?>" target="blank">
    <input    type="text" name="book_id"  value="<?php echo 
$ResultsRow['id'] ?>"> 
</div>
  </div>
</a> <!-- end of link  -->
..........

Secondpage.php (where i want to retrieve book id):

  ....
   <p> <?php  $myvarC = $_POST['identity'];
             echo $myvarC;
         ?> </p>
   ....

5 answers

  • answered 2018-01-16 12:38 Andreas Andersson

    You can include it in the urlquery like shopping.php?id=1234 and then read it on the other side.

  • answered 2018-01-16 12:38 roman reign

    You can do this by $_GET;

    First Page

    <a href="shopping.php?id=<?php echo $identity?>" target="blank">
    

    Second Page

    <?php  $myvarC = $_GET['id'];
                 echo $myvarC;
             ?>
    

  • answered 2018-01-16 12:38 Ashish Tiwari

    I think you should try something like below:

    firstpage.php

    <a href="shopping.php?identity=<?php echo $identity?>" target="blank">
    

    secondpage.php

    <p> <?php  $myvarC = $_GET['identity'];
        echo $myvarC;
    ?> </p>
    

  • answered 2018-01-16 12:38 Daniel Paiva

    First Page

    <a href="shopping.php?identity=<?php echo $identity?>" target="blank">
    

    Second Page

    <p> <?php  $myvarC = $_REQUEST['identity'];
             echo $myvarC;
         ?> </p>
    

  • answered 2018-01-16 12:38 Marçal Berga

    Create a correct url with parameters

    <a href="shopping.php?id=<?php echo $identity?>" target="_blank">
    

    And get that value using

    <?php 
    $myVarC = $_GET['id'];
    echo $myVarC 
    ?>