I want the last 3 searches to be saved in a Cookie and displayed in a '< p>' tag. Here is my HTML code:
<form class="Dform" method="POST" action="index.php">
<input type="text" name="search" value="">
<input type="submit" name="" value="Search">
</form>
I only managed to display the previous search but I don't know how to do the 2 previous ones, here is my php code:
<?php
if (!empty($_POST['search']))
{
setcookie('PreviousSearch', $_POST['search'], time()+60*60,'',localhost);
}
?>
<?php
$r1 = htmlspecialchars($_COOKIE['PreviousSearch']);
echo '<p> Previous search (1) : '.$r1.'</p>';
?>