The problem now is, the cookie is made, it is still ther, but when you are plasing an order and you want to go back to the order list, It only shows that the cookie exists and doesn't show the name enymore, wher it should be shown. The name must be shown again, after a second visit.
Her is my compleet sorce code.
<?php
$NewNaam = $_POST['NewNaam'];
//setcookie('Naam', '', time()-1000);
if (isset($_COOKIE['Naam'])) {
$Naam = $NewNaam;
echo 'cookie exists' ;
} else {
$cookieset = setcookie('Naam', $NewNaam, time()+40000);
if (!empty($cookieset)) {
$Naam = $NewNaam;
echo 'new cookie set';
} else {
echo 'error - cookie could not be set';
}
}
// Hier wordt Cookie gemaakt als hij nog niet bestaant
?>
<?php /*-------------------------------------------------------------------------------------------------------------------*/?>
<?php /*-------------------------------------------------------------------------------------------------------------------*/?>
<?php require_once('Connections/Verbinding.php'); ?>
<?php
mysql_select_db($database_Verbinding, $Verbinding);
$query_Recordset2 = "SELECT * FROM nieuws ORDER BY NieuwsID DESC";
$Recordset2 = mysql_query($query_Recordset2, $Verbinding) or die(mysql_error());
$row_Recordset2 = mysql_fetch_assoc($Recordset2);
$totalRows_Recordset2 = mysql_num_rows($Recordset2);
mysql_select_db($database_Verbinding, $Verbinding);
$query_Recordset1 = "SELECT * FROM produkten ORDER BY NaamProdukt ASC";
$Recordset1 = mysql_query($query_Recordset1, $Verbinding) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
?>
<?php /*-------------------------------------------------------------------------------------------------------------------*/?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>| Bikkertjes - intranet website |</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body background="Interface-bestellijst.jpg" link="#FFFFFF" vlink="#FFFFFF" alink="#FFFFFF">
<table width="96%" border="0">
<tr>
<td colspan="2"> </td>
<td colspan="3"> </td>
</tr>
<tr>
<td colspan="2"> </td>
<td colspan="3"> </td>
</tr>
<tr>
<td height="31" colspan="2"> </td>
<td colspan="3"> </td>
</tr>
<tr>
<td width="4"> <div align="left"><strong></strong></div></td>
<td width="132"><font color="#FFFFFF" size="1" face="Verdana, Arial, Helvetica, sans-serif"><strong>Main
menu</strong></font></td>
<td colspan="3"><strong></strong></td>
</tr>
<tr>
<td colspan="2"> </td>
<td colspan="3"> </td>
</tr>
<tr>
<td height="754" colspan="2" valign="top"><font color="#FFFFFF" size="1" face="Verdana, Arial, Helvetica, sans-serif">-
<a href="index.htm">Main</a></font><font size="1" face="Verdana, Arial, Helvetica, sans-serif"> </font><font size="1" face="Verdana, Arial, Helvetica, sans-serif"><br>
<font color="#FFFFFF">- <a href="nieuws.php" target="_self">Nieuws</a><br>
- <a href="Frietzak.php" target="_self">Frietzak</a><br>
- <a href="product-list.php" target="_self">Bestellen</a><br>
- <a href="login.htm" target="_self">Admin</a></font></font></td>
<td width="4" valign="top"> </td>
<td width="475" valign="top">
<p> </p>
<p><font color="#FFFFFF" size="1" face="Verdana, Arial, Helvetica, sans-serif"><strong>Hallo
<?php ($_COOKIE["Naam"] && !$_GET[$Naam]); //Cookie ophalen met functie $_Cookie["Naam"] && !$_GET[Variable ophalen]
print ("<font face=\"verdana\" size=1 color=\"white\"> $Naam\n"); //Print de Variable $Naam op beeldscherm.
?>
</strong></font></p>
<table width="100%" border="0" cellspacing="1" cellpadding="1">
<tr>
<td bgcolor="#000000"><table width="475" border="0" cellpadding="1" cellspacing="1">
<tr bgcolor="#333333">
<td width="128"><font color="#FFFFFF" size="1" face="Verdana, Arial, Helvetica, sans-serif">ProduktID</font></td>
<td width="168"><font color="#FFFFFF" size="1" face="Verdana, Arial, Helvetica, sans-serif">NaamProdukt</font></td>
<td width="108"><font color="#FFFFFF" size="1" face="Verdana, Arial, Helvetica, sans-serif">Prijs</font></td>
<td width="82"><font color="#FFFFFF" size="1" face="Verdana, Arial, Helvetica, sans-serif">Bestel</font></td>
</tr>
<?php do { ?>
<tr>
<td bgcolor="#333333"><font color="#FFFFFF" size="1" face="Verdana, Arial, Helvetica, sans-serif"><?php echo $row_Recordset1['ProduktID']; ?></font></td>
<td bgcolor="#666666"><font color="#FFFFFF" size="1" face="Verdana, Arial, Helvetica, sans-serif"><?php echo $row_Recordset1['NaamProdukt']; ?></font></td>
<td bgcolor="#666666"><font color="#FFFFFF" size="1" face="Verdana, Arial, Helvetica, sans-serif"><?php echo $row_Recordset1['Prijs']; ?></font></td>
<?php /*-------------------------------------------------------------------------------------------------------------------*/?>
<td bgcolor="#666666">
<?php
$item_id= $row_Recordset1['ProduktID']; //Haalt ProduktID op uit recordset en stopt hem in $item_id
$user_name= $Naam; //Haalt ProduktNaam op uit recordset en stopt hem in $item_name
echo "<font face=\"verdana\" size=1 color=\"white\" ><a href='
http://localhost/test/bestellijst.php?P ... >Bestel</a>";
?>
</td>
<?php //Maakt een link die zich zelf herhaalt op moment van uitvoeren. Parameters zijn $item_id en $item_name ?>
<?php //De parameters worden mee gestuurd naar de pagina bestellijst.php daar zullen ze worden opgehaald met $_POST ?>
<?php /*-------------------------------------------------------------------------------------------------------------------*/?>
</tr>
<?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?>
</table></td>
</tr>
</table>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<td width="475" valign="top"> </td>
</tr>
<tr>
<td colspan="2"> </td>
<td colspan="3"> </td>
</tr>
<tr>
<td height="10" colspan="2"> </td>
<td colspan="3"> </td>
</tr>
<tr>
<td height="10" colspan="2"> </td>
<td colspan="3"> </td>
</tr>
<tr>
<td height="10" colspan="2"> </td>
<td colspan="3"> </td>
</tr>
</table>
</body>
</html>
<?php
mysql_free_result($Recordset2);
mysql_free_result($Recordset1);
?>