I'm setting two cookies in a page called reservation.php where i read the content of two input through $POST method,
if (isset($_POST['chambre']) && isset($_POST['option_chambre']) )
{
setcookie('preference',$_POST['option_chambre'],time()+3600*24*31,"http://127.0.0.1/partie_3_f/accueil.php",null, false, true);
setcookie('type',$_POST['chambre'],time()+3600*24*31,"http://127.0.0.1/partie_3_f/accueil.php",null, false, true);
}
Then in other page i'm trying to check the DB and show the results where the value of two colums will have the same value as the one stocked in the cookies
<?php
{
$con = mysqli_connect('localhost','root','root','pdxhotel');
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$type=$_COOKIE['type'];
$pre = $_COOKIE['preference'];
$soal = $con->query("select * from chambre where vide = 1 and type_chambre='".$type."' and preference = '".$pre."'");
if (mysqli_num_rows($soal)==0)
{
echo "pas de chambre disponible";
}
else
{
?>
<div id="titres" align="center">
<label >----------------------------</label>
<h2 id="tit"> Resultat de recherche </h2>
<label >----------------------------</label>
</div>
<?php
for ($i = 0; $i<mysqli_num_rows($soal); $i++)
{
?>
<div id="offre1" class="offre">
<img src="Images/chambre3.jpg" width="100%" height="50%" />
<p > <?php echo "Chambre de type",$_COOKIE['type'],"and qui vérifie la condition:",$_COOKIE['preference']?> </p>
</div>
<?php
}
}
}
?>
I'm having a problem Notice: Array to string conversion ! It's my first time to work with cookies can you please tell me what's wrong and what should i do ?