Bonjour,
J'ai ce code qui permet de faire un sondage lié à d'autres pages php bien sûr :
Je souhaiterais afficher une boite de message en javascript lorsqu'on clique sur le bouton submit alors qu'aucun choix n'est encore fait. Une fonction javascript en php qui permet de rester sur la page si aucun choix n'est fait
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54 <? //insertion de fichier de configuration require("config.php"); // connection et selection de la base ce donnée $connect=mysql_connect($host,$login,$pass) or die ("Connection impossible"); mysql_select_db($base,$connect) or die ("selection impossible"); // création de la table si elle n'existe pas $select = "SELECT COUNT(*) FROM ".$table.""; $query = mysql_query($select,$connect); if(!$query){ $requete = " CREATE TABLE $table (id INT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY, choix VARCHAR(255) NOT NULL, vote INT(11) NOT NULL, total_vote INT(11) NOT NULL)"; mysql_query($requete,$connect); //insertion des choix du sondage(tableau $choix) $i = 0; while($i<count($choix)){ mysql_query("INSERT INTO ".$table." (choix) VALUES('".$choix[$i]."')"); $i++; } } // affichage du formulaire de sondage $affich_form=mysql_query("SELECT * FROM ".$table.""); echo"<div align='center'>"; echo"<font size='".$size."' color='".$color."'><b>".$titre_sondage."</b></font>"; echo" "; echo"<table border='0' width='200'><tr><td>"; echo"<div align='center'><form name='voter' method='post' action='sondage/vote.php'>"; // recupération des choix dans la base de donnée while($tab=mysql_fetch_array($affich_form,MYSQL_ASSOC)){ echo"<div align='left'><input type='radio' name='id' value='".$tab['id']."'>"; echo"<font size='".$size."' color='".$color."'><b>".$tab['choix']."</b></font><br>"; } echo"<br>"; echo"<div align='center'><input type='submit' value='Voter'>"; echo"</form>"; echo"<a href='sondage/resulta.php'><font size='".$size."'>Voir les résultats<font></a>"; echo"</td></tr></table>"; echo"</div>"; // fermeture de connection à la base mysql_close(); ?>
Je vous remercie pour votre aide !
Partager