Hej!
Jag har gjort ett röstningsscript och när man röstar så ske det sparas en kaka så att man inte ska kunna rösta flera gånger, men det funkar inte.
[kod]
<?php
setcookie ("voted", "yes",time()+31536000);
if (!isset($voted)) {
$vfile = fopen("data/poll.txt","r+");
$antal_ja = str_replace("\n", "", fgets($vfile, 1024));
$antal_nej = str_replace("\n", "", fgets($vfile, 1024));
fclose($vfile);
if ($vote=="ja") {
$antal_ja = $antal_ja + 1;
}
elseif ($vote=="nej") {
$antal_nej = $antal_nej + 1;
}
$vfile = fopen("data/poll.txt","w+");
fputs($vfile, "$antal_ja\n");
fputs($vfile, "$antal_nej\n");
fclose($vfile);
}
header("Location: index.php?id=huvudsidan");
?>
[kod]
------------------
[klicka exakt precis här]