bonjour,
je suis entrain de crée un sondage sur un site afin d'avoir les opinions des visiteurs....
Sur ce sondage, je souhaite le visiteur puissent voté uniquement une seule fois par sondage crée.
Mon probléme lorsque le sondage comprend plusieurs vote, à chaque actualisation ou retour sur la page le sondage comptabilise le dernier vote dans la base de donnée.
voici le script posant probléme
j'insere le vote dans la bdd
je selectionne si ya deja une ip pour ce sondage alors j'affiche avec le bouton voter:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5 $vote_ip = $_SERVER['REMOTE_ADDR']; $sondage_id = $numeroDuSondage['nbre_entrees']; $sql = "INSERT INTO t_vote (sondage_id, vote_ip) VALUES ($sondage_id, '$vote_ip')"; mysql_query($sql) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error());
sinon sans le bouton voter: ici à chaque actualisation de la page , il comptabilise un vote:
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 if(!mysql_num_rows(mysql_query('SELECT * FROM t_vote WHERE sondage_id='.$sondage_id.' AND vote_ip="'.$vote_ip.'"')) > 0){ //sondage avec bouton avant validation echo '<img src="img/_sondage.gif"><br>'; echo '<div class="archives">'.$infos['question'].'</div>'.''. ""; echo '<div class="date">'.$infos['proposition1'].'</div>'.''. "<input type='radio' name='sondage' value='prop1' id='prop1' /> <label for='prop1'>" .'<img src="img/sondage/vert.gif" height="16" width="' . $pourcentage_r1 / 100 * $long_max_bloc . '" alt="'.round($pourcentage_r1).'%" />' . '<img src="img/sondage/vert_droite.gif"/>' . round($pourcentage_r1) . "%<br />"; echo '<div class="date">'.$infos['proposition2'].'</div>'.''. "<input type='radio' name='sondage' value='prop2' id='prop1' /> <label for='prop1'>" .'<img src="img/sondage/rouge.gif" height="16" width="' . $pourcentage_r2 / 100 * $long_max_bloc . '" alt="'.round($pourcentage_r2).'%" />' . '<img src="img/sondage/rouge_droite.gif"/>' . round($pourcentage_r2) . "% <br />"; if ($infos['proposition3'] != "") echo '<div class="date">'.$infos['proposition3'].'</div>'.''. "<input type='radio' name='sondage' value='prop3' id='prop1' /> <label for='prop1'>" .'<img src="img/sondage/jaune.gif" height="16" width="' . $pourcentage_r3 / 100 * $long_max_bloc . '" alt="'.round($pourcentage_r3).'%" />' . '<img src="img/sondage/jaune_droite.gif"/>' . round($pourcentage_r3) . "% <br />"; if ($infos['proposition4'] != "") echo '<div class="date">'.$infos['proposition4'].'</div>'.''. "<input type='radio' name='sondage' value='prop4' id='prop1' /> <label for='prop1'>" .'<img src="img/sondage/orange.gif" height="16" width="' . $pourcentage_r4 / 100 * $long_max_bloc . '" alt="'.round($pourcentage_r4).'%" />' . '<img src="img/sondage/orange_droite.gif"/>' . round($pourcentage_r4) . "% <br />"; if ($infos['proposition5'] != "") echo '<div class="date">'.$infos['proposition5'].'</div>'.''. "<input type='radio' name='sondage' value='prop5' id='prop1' /> <label for='prop1'>" .'<img src="img/sondage/bleu.gif" height="16" width="' . $pourcentage_r5 / 100 * $long_max_bloc . '" alt="'.round($pourcentage_r5).'%" />' . '<img src="img/sondage/bleu_droite.gif"/>' . round($pourcentage_r5) . "% <br />"; echo '<input type="submit" name="voter" value="Voter !"/><br /><br /><br /><br />'; echo '<div align="right" class="archive"><a href="index.php?rub=game-editor">les résultats des anciens sondages +</a></div>'; echo '<br/><br/><br/><br/><br/>'; }
je n'arrive à voir ou provient l'erreur et le pourquoi?
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 else { echo '<img src="img/_sondage.gif"><br>'; if ($infos['question'] != "") echo '<div class="archives">'.$infos['question']. ""; echo '</div>'; if ($infos['proposition1'] != "") echo '<div class="date">'.$infos['proposition1'].'</div>'.''.'<img src="img/sondage/vert.gif" height="16" width="' . $pourcentage_r1 / 100 * $long_max_bloc . '" alt="'.round($pourcentage_r1).'%" />' . round($pourcentage_r1) . "%"; if ($infos['proposition2'] != "") echo '<div class="date">'.$infos['proposition2'].'</div>'.''.'<img src="img/sondage/rouge.gif" height="16" width="' . $pourcentage_r2 / 100 * $long_max_bloc . '" alt="'.round($pourcentage_r2).'%" />' . round($pourcentage_r2) . "% "; if ($infos['proposition3'] != "") echo '<div class="date">'.$infos['proposition3'].'</div>'.''.'<img src="img/sondage/jaune.gif" height="16" width="' . $pourcentage_r3 / 100 * $long_max_bloc . '" alt="'.round($pourcentage_r3).'%" />' . round($pourcentage_r3) . "% "; if ($infos['proposition4'] != "") echo '<div class="date">'.$infos['proposition4'].'</div>'.''.'<img src="img/sondage/orange.gif" height="16" width="' . $pourcentage_r4 / 100 * $long_max_bloc . '" alt="'.round($pourcentage_r4).'%" />' . round($pourcentage_r4) . "% "; if ($infos['proposition5'] != "") echo '<div class="date">'.$infos['proposition5'].'</div>'.''.'<img src="img/sondage/bleu.gif" height="16" width="' . $pourcentage_r5 / 100 * $long_max_bloc . '" alt="'.round($pourcentage_r5).'%" />' . round($pourcentage_r5) . "% <br /><br /><br /><br />"; echo '<div align="right" class="archive"><a href="index.php">les résultats des anciens sondages +</a><br><br><br>'; echo '<br/><br/><br/><br/><br/>'; echo '</div>'; }
si une âme pourrais m'expliquer et me montrer avec beaucoup commentaire que je puisse progresser.....
merci beaucoup
sam
Partager