Jeg ved ikke, hvad det kan skyldes, men min cookie slettes hver gang browseren bliver lukket ned.
<?php
$video = mysql_fetch_assoc(mysql_query("SELECT * FROM videoer WHERE videoID=$_GET[videoID]"));
if ($_COOKIE['voted'] == $video['navn']) {
$votecookies = "no";
} else {
$votecookies = "yes";
}
if($votecookies == "yes"){
if(isset($_GET['vote']) && $_GET['vote'] != ""){
$total_antal = $video['antal_votes']+1;
$total_rate = $video['rate']+$_GET['vote'];
mysql_query("UPDATE videoer SET rate=$total_rate, antal_votes=$total_antal WHERE videoID=$video[videoID]");
setcookie("voted", $video['navn']);
$location = "jukebox.php?videoID=$video[videoID]";
header("location: $location");
}
}
?>
<?php include('inc/header.php'); ?>
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="bluebox">
<tr>
<td><strong>Titel</strong></td><td><?php echo $video['navn']; ?></td>
</tr>
<tr>
<td><strong>Dato</strong></td><td><?php echo $video['dato']; ?></td>
</tr>
<tr>
<form>
<td><strong>Ratings</strong></td><td>
<?php
if($video['rate'] != "" && $video['antal_votes'] != ""){
$rating_total = $video['rate']/$video['antal_votes'];
$antal_total = $video['antal_votes'];
}else{
$rating_total = "0";
$antal_total = "0";
}
for ($i = 1; $i <= $rating_total; $i++ )
{
echo "<img src=\\"billeder/ikoner/star.gif\\" align=\\"absmiddle\\">";
}
echo "(".round($rating_total, 2).")";
if($votecookies == "yes"){
?>
<select name="rate" OnChange="JumpToFunc(this)">
<option value="" selected>-</option>
<option value="jukebox.php?videoID=<?php echo $_GET['videoID']; ?>&vote=1">1</option>
<option value="jukebox.php?videoID=<?php echo $_GET['videoID']; ?>&vote=2">2</option>
<option value="jukebox.php?videoID=<?php echo $_GET['videoID']; ?>&vote=3">3</option>
<option value="jukebox.php?videoID=<?php echo $_GET['videoID']; ?>&vote=4">4</option>
<option value="jukebox.php?videoID=<?php echo $_GET['videoID']; ?>&vote=5">5</option>
</select>
<SCRIPT LANGUAGE="Javascript">
function JumpToFunc(name)
{
if (name.options[name.selectedIndex].value != '')
{
window.location = name.options[name.selectedIndex].value
}
}
</SCRIPT>
<?php
}
?>
</td>
</form>
</tr>
<tr>
<td><strong>Antal stemmer</strong></td><td><?php echo $antal_total; ?></td>
</tr>
<tr>
<td><strong>Beskrivelse</strong></td><td><?php echo $video['tekst']; ?></td>
</tr>
<tr>
<td colspan="2" align="center">[<a href="videoer.php">Tilbage</a>]</td>
</tr>
</table>
<?php include('inc/footer.php'); ?>