i have poll system and i want to restrict the voting for 5 sec after voting. I have problem with URL ID, because when i click on text (vote) it´s not working, but after second click it works. I think it´s because the system take the +1 vote from URL ID. Sorry for my English :D
Here is a script:
<h2>Ankety</h2>
<?php if(isset($_COOKIE['hlas'])) {
$ankety = mysqli_query($connection, "SELECT * FROM ankety ORDER BY id DESC;");
$row = mysqli_fetch_all($ankety);
foreach ($row as $anketa) {
$odpovedeQuery = mysqli_query($connection, "SELECT * FROM odpovede WHERE anketa_id='".$anketa[0]."';");
$odpovede = mysqli_fetch_all($odpovedeQuery);
echo '<h3 style="margin: 0;">'.$anketa[0].'. '.$anketa[1].'</h3>';
foreach ($odpovede as $odpoved)
{
echo '<a href="?id='.$odpoved[0].'" >','<br />' .$odpoved[2].' - ('.$odpoved[3].')</a> ';
}
echo '<br /><br />';
}
} else {
mysqli_query($connection, "UPDATE odpovede SET pocet = pocet + '1' WHERE id = '".$_GET['id']."';");
$ankety = mysqli_query($connection, "SELECT * FROM ankety ORDER BY id DESC;");
$row = mysqli_fetch_all($ankety);
foreach ($row as $anketa) {
$odpovedeQuery = mysqli_query($connection, "SELECT * FROM odpovede WHERE anketa_id='".$anketa[0]."';");
$odpovede = mysqli_fetch_all($odpovedeQuery);
echo '<h3 style="margin: 0;">'.$anketa[0].'. '.$anketa[1].'</h3>';
foreach ($odpovede as $odpoved)
{
echo '<a href="?id='.$odpoved[0].'" >','<br />' .$odpoved[2].' - ('.$odpoved[3].')</a> ';
SetCookie('hlas','1', time()+(5));
}
echo '<br /><br />';
}
}
?>
How to make it without using URL ID? I don´t wanna to restrict it via IP address.