I am designing a real estate website i have many ads in my website and when user click on a certain ad it goes to another page viewmore.php
which gives user more details about that certain ad.
Now as you see in viewmore.php
file I save ad's id in cookies and send ad's id to the favorite page and user can review that post any time he or she wants in favorite page.
The problem:
consider that i visit this page localhost/viewmore.php?ID=10
thus when you go to favorite page u see the ad data which belong to this id but when you visit another ad like localhost/viewmore.php?ID=11
and you go to the favorite page you see the ad data which belong to id=11
and previous add is gone. i want to save both of them in my favorite page or as a matter of fact save all the posts i visit.
how can i do that?
//reviewmore.php
<!doctype html>
<?php
(is_numeric($_GET['ID'])) ? $ID = $_GET['ID'] : $ID = 1;
?>
<?php
$cookie_name = "favoritepost";
$cookie_value ="$ID";
setcookie($cookie_name, $cookie_value, time() + (86400 * 30), "/"); // 86400 = 1 day
?>
<html>
<body>
<?php
error_reporting(0);
include("config.php");
(is_numeric($_GET['ID'])) ? $ID = $_GET['ID'] : $ID = 1;
$result = mysqli_query($connect,"SELECT*FROM ".$db_table." WHERE idhome = $ID");
?>
<?php
error_reporting(0);
include("config.php");
(is_numeric($_GET['ID'])) ? $ID = $_GET['ID'] : $ID = 1;
$result = mysqli_query($connect,"SELECT*FROM ".$db_table." WHERE idhome = $ID");
?>
<?php $row = mysqli_fetch_array($result):
$price=$row['price'];
$rent=$row['rent'];
$room=$row['room'];
$date=$row['date'];
?>
<?php
echo"price";
echo"room";
echo"date";
?>
</body>
</html>
favoritepage.php
<!doctype html>
<html>
<body>
<?php
$cookie_name = "favoritepost";
?>
<?php
error_reporting(0);
include("config.php");
$result = mysqli_query($connect,"SELECT*FROM ".$db_table." WHERE idhome = $_COOKIE[$cookie_name]");
?>
<?php $row = mysqli_fetch_array($result):
$price=$row['price'];
$rent=$row['rent'];
$room=$row['room'];
$date=$row['date'];
?>
<?php
echo"price";
echo"room";
echo"date";
?>
</body>
</html>