Bonjour à tous,
voici mon problème : J'ai une liste de choix que j'aimerai utiliser pour afficher/masquer le bon formulaire.
exemple :
choix : Ajouter un collaborateur -> form -> annuaire_new
choix : Modifier un collaborateur -> form -> annuaire_modif
choix : Supprimer un collaborateur -> form -> annuaire_delete
voici aujourd'hui mon code :
Liste déroulante :
Exemple d'un form :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10 <table class="metrologie"> <form name="annuaire_choix" method="post" action="annuaire_new.php"> <label for="choix">Que voulez vous faire :</label><br> <select name="choix" id="choix"> <option value="Ajouter">Ajouter un collaborateur</option> <option value="Modifier" >Modifier un collaborateur</option> <option value="Supprimer" >Supprimer un collaborateur</option> </select><br> </form>
Action php via le form annuaire_new :
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 <form name="annuaire_new" method="post" action="annuaire_new.php"> <tr class='titre'><td colspan=3><u>Personnel :</u></td></tr> <td> <label for="nom">Nom :</label><br> <input name="nom" type="text" id="nom"><br> <label for="prenom">Prénom :</label><br> <input name="prenom" type="text" id="prenom"> </td> <br> <tr class='titre'><td colspan=3><u>Lieu :</u></td></tr> <td> <label for="site">Site :</label><br> <select name="site" id="site"> <option value="001">001</option> <option value="002" >002</option> <option value="003" > 003</option> <option value="004" > 004</option> <option value="005" >005</option> </select><br> <label for="localisation">Localisation :</label><br> <input name="localisation" type="text" id="localisation" > </td> <br> <tr class='titre'><td colspan=3><u>Coordonnées :</u></td></tr> <td> <label for="teltravail">Téléphone Travail :</label><br> <input name="teltravail" type="text" id="teltravail"><br> <label for="teltravail2">Téléphone travail 2 :</label><br> <input name="teltravail2" type="text" id="teltravail2"><br> <label for="fax">Fax :</label><br> <input name="fax" type="text" id="fax"><br> <label for="portable">Portable :</label><br> <input name="portable" type="text" id="portable"><br> <label for="bip">Bip :</label><br> <input name="bip" type="text" id="bip"><br> <label for="numeroabrege">Numéro abrégé :</label><br> <input name="numeroabrege" type="text" id="numeroabrege"><br> <input name="" type="submit" value="Enregistrer"> </td> </form>
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 <?php if (isset($_REQUEST['choix']) && $_REQUEST['choix'] == 'Ajouter') { // si on a cliqué sur "Enregistrer" # Connexion à la base de données $liendb = mysql_connect("localhost", "root", ""); mysql_select_db ("annuaire"); # Insertion de la nouvelle entrée $sql = "INSERT INTO employes (nom, prenom, site, localisation, teltravail, teltravail2, fax, portable, bip, numeroabrege, areva) VALUES ('".$_REQUEST['nom']."', '".$_REQUEST['prenom']."', '".$_REQUEST['site']."', '".$_REQUEST['localisation']."', '".$_REQUEST['teltravail']."', '".$_REQUEST['teltravail2']."', '".$_REQUEST['fax']."', '".$_REQUEST['portable']."', '".$_REQUEST['bip']."', '".$_REQUEST['numeroabrege']."',)"; # Execution de la requete mysql_query ($sql); # Fermeture de la base de données mysql_close($liendb); } ?>








Répondre avec citation
Partager