Bonjour, j'ai essayer de créer un système de sondage, mais j'ai plusieurs problème (enfin beaucoup)
La page du formulaire :
La page de traitement :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 <?php mysql_connect("localhost", "root", ""); mysql_select_db("test"); $retour = mysql_query('SELECT * FROM sondage'); while ($affiche = mysql_fetch_array($retour)) { ?> <form method="post" action="votez.php"/> <h4><?php echo $affiche['question']; ?></h4> <hr> <p><input type="radio" name="sondage" value="<?php echo $affiche['reponse1']; ?>" id="<?php echo $affiche['reponse1']; ?>" /> <label for="<?php echo $affiche['reponse1']; ?>"><?php echo $affiche['reponse1']; ?></label><br /> <input type="radio" name="sondage" value="<?php echo $affiche['reponse2']; ?>" id="<?php echo $affiche['reponse2']; ?>" /> <label for="<?php echo $affiche['reponse2']; ?>"><?php echo $affiche['reponse2']; ?></label><br /> <input type="radio" name="sondage" value="<?php echo $affiche['reponse3']; ?>" id="<?php echo $affiche['reponse3']; ?>" /> <label for="<?php echo $affiche['reponse3']; ?>"><?php echo $affiche['reponse3']; ?></label><br /> <input type="radio" name="sondage" value="<?php echo $affiche['reponse4']; ?>" id="<?php echo $affiche['reponse4']; ?>" /> <label for="<?php echo $affiche['reponse4']; ?>"><?php echo $affiche['reponse4']; ?></label></p> <hr> <input type="hidden" name="id" value="<?php echo $affiche['id']; ?>" /> <input type="hidden" name="ip_voteur" value="<?php echo $_SERVER['REMOTE_ADDR']; ?>" /> <input type="submit" value="Envoyer !"/> </form> <?php } ?>
Donc, le problème c'est que je n'arrive pas à faire en sorte que le membre doit voter qu'une seule fois est pas autant qu'il veut..
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28 <?php mysql_connect("localhost", "root", ""); mysql_select_db("test"); if (isset($_POST['sondage'])) { $choix = addslashes($_POST['sondage']); $id = addslashes($_POST['id']); $ip_voteur = addslashes($_POST['ip_voteur']); $requete = mysql_query(' SELECT id_reponse FROM reponse WHERE id_reponse=\'' . $id . '\''); $verif = mysql_fetch_assoc($requete); if($ip_voteur != $verif['id_reponse']) { mysql_query("INSERT INTO reponse VALUES('', '" . $choix . "', '" . $ip_voteur . "')"); echo'<p>Sondage enregistrer avec sucées !</p>'; } } else { echo'<p>Le sondage n\'a pas pu être enregistrer !<br /> Ou alors vous avez déjà voter !</p>'; } ?>
Sinon, je ne c'est pas du tout comment m'y prendre pour faire la page resultat.php. Pour afficher par exemple : 35.4% ?
Par avance, merci.
Partager