Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

114
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda