i want to send the cookie to another page that store the id from database retrieve value . the thing is it is send to the next page and also working. there is book record retrieve from database with image and one button . i have store the id of the book. but when it goes to next page it displays first book id no matter which book i select by the button
this is code where i set cookie
echo "<form action='issue.php' method='get'>";
while ($row= mysqli_fetch_array($result)) {
echo "<div id='img_div'> ";
echo "<img src='books/".$row['image']."'>";
// echo "</div>";<div id='text'>
echo " <table>";
echo "<tr><td> NAME</td><td> ".$row['name']."</td></tr>";
echo "<tr><td> AVAILABILITY</td><td> ".$row['availabilty']."</td></tr>";
echo "<tr><td> CATEGORY</td><td> ".$row['category']."</td></tr>";
echo "<tr><td colspan='2'>
<button type='submit' name='issue'>issue</button></td></tr>";
echo "</table>";
echo "</div><br/>";
if (isset($_GET['issue'])) {
# code...
$bookid=$row['isbn'];
setcookie("bid",$bookid);
if(!isset($_COOKIE['bid'])){
echo "COOKIE NOT SET";
}
else{
echo "COOKIE SET SUCCESSFULLY";
}
}
And this is code where i access the cookie next page
$id=$_SESSION['user']['username'];
$query = "select id from user_account where username='$id'";
$result=mysqli_query($con,$query);
$row= mysqli_fetch_assoc($result);
$uid=$row['id'];
// if (mysqli_num_rows($results) == 1) {
// $row= mysqli_fetch_assoc($results);
//
// }
$bookid=$_COOKIE['bid'];
echo "$uid";
echo "<br/>";
echo "$bookid";
$query = "INSERT INTO issue (bookid, userid)
VALUES ('$bookid', '$uid')";
mysqli_query($con, $query)or die(mysqli_error($con));