Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

112
Views
How to restrict voting in poll using Cookie

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.

over 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!