Bonjour,
Je suis nouveau ici et je viens vers vous car j'ai besoin de votre précieuse aide. Je suis en stage pour mon BTS et je doit créer un petit site web pour mon stage. Hier, toute les fonctionnalitées marché à peu près bien mais la j'ai du toucher quelque chose et sa fait un jour que j'ai beau chercher, j'arrive pas a mettre le doigt dessus. Je me tourne donc vers vous
1er problème :
En enlevant le header, le formulaire fonctionne avec aucune erreur ainsi que la modification dans la base ! Mais du coup mon formulaire s'actualise pas et affiche l'ancienne version de l'enregistrement
Voici le code :
client.form.modifier.php:
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
55
56
57
58
59
60
61
62
63
64
65
66 <!DOCTYPE html> <html> <head> <title>Modifier un client</title> </head> <body onunload="window.opener.location.reload(true);"> <?php include "../include/fonctions.php"; $connex = connexion_bd(); if (isset($_GET['client_id'])) { $req="SELECT Num_Client, Nom_Client, Prenom_Client, Adresse_Client, Ville_Client, CP_Client, Telephone_Client, Portable_Client, Mail_Client FROM CLIENT WHERE Num_Client=?"; $prep=$connex->prepare($req); $prep->bindValue(1, $_GET["client_id"]); $prep->execute(); $row=""; $row=$prep->fetch(PDO::FETCH_OBJ); if(isset($_POST['envoyer'])) { $req="UPDATE CLIENT SET Nom_Client=?, Prenom_Client=?, Adresse_Client=?, Ville_Client=?, CP_Client=?, Telephone_Client=?, Portable_Client=?, Mail_Client=? WHERE Num_Client=?"; $prep=$connex->prepare($req); $prep->bindValue(1, $_POST['Nom_Client']); $prep->bindValue(2, $_POST['Prenom_Client']); $prep->bindValue(3, $_POST['Adresse_Client']); $prep->bindValue(4, $_POST['Ville_Client']); $prep->bindValue(5, $_POST['CP_Client']); $prep->bindValue(6, $_POST['Telephone_Client']); $prep->bindValue(7, $_POST['Portable_Client']); $prep->bindValue(8, $_POST['Mail_Client']); $prep->bindValue(9, $_GET['Num_Client']); $prep->execute(); header("Location:../formulaire/client.form.modifier.php"); } } ?> <form name="modifier" method="post" action=""> <legend><b><i>Modifier un client</i></b></legend> <p>Nom : <input value="<?php echo $row->Nom_Client;?>" name="Nom_Client" id="modifie"></p> <p>Prénom : <input value="<?php echo $row->Prenom_Client;?>" name="Prenom_Client" id="modifie"></p> <p>Adresse : <input value="<?php echo $row->Adresse_Client;?>" name="Adresse_Client" id="modifie"></p> <p>Ville :<input value="<?php echo $row->Ville_Client;?>" name="Ville_Client" id="modifie"></p> <p>Code postal :<input value="<?php echo $row->CP_Client;?>" name="CP_Client" id="modifie"></p> <p>Téléphone :<input value="<?php echo $row->Telephone_Client;?>" name="Telephone_Client" id="modifie"></p> <p>Portable :<input value="<?php echo $row->Portable_Client;?>" name="Portable_Client" id="modifie"></p> <p>E-Mail :<input value="<?php echo $row->Mail_Client;?>" name="Mail_Client" id="modifie"></p> <input type="submit" name="envoyer" id="bouton" value="Envoyer"> </form> </body> </html>
client.php :
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110 <!DOCTYPE html> <html> <head> <title>Client</title> <script type="text/javascript"> function ajoutclientpop(){ width = 300; height = 500; if(window.innerWidth){ var left = (window.innerWidth-width)/2; var top = (window.innerHeight-height)/2; } else{ var left = (document.body.clientWidth-width)/2; var top = (document.body.clientHeight-height)/2; } window.open('../formulaire/client.form.ajouter.php','Ajout client','menubar=no, scrollbars=no, top='+top+', left='+left+', width='+width+', height='+height+''); } function PopupWindow(source, strWindowToOpen){ var strWindowFeatures = "toolbar=no,resize=no,titlebar=no,"; strWindowFeatures = strWindowFeatures + "menubar=no,width=300,height=500,maximize=null"; window.open(strWindowToOpen, '', strWindowFeatures); } </script> </head> <body> <?php include "../include/fonctions.php"; $connex = connexion_bd(); $req="SELECT Num_Client, Nom_Client, Prenom_Client, Adresse_Client, Telephone_Client, Portable_Client, Ville_Client, CP_Client, Mail_Client FROM CLIENT"; $res=$connex->query($req); $donnees=""; if(isset($_POST['delete'])){ if (isset($_POST['del'])){ if(count($_POST['del']) >=1){ $connex->exec('DELETE FROM CLIENT WHERE Num_Client IN (' . implode(', ', array_map('intval', $_POST['del'])) . ')'); header("Location:client.php"); } } else{ } } ?> <form method='POST' action='client.php'> <table> <input type="submit" name="delete" id="delete" class="delete" value="Supprimer la sélection"> <input type="button" value="Ajouter un client(e)" onclick="location.href='javascript:ajoutclientpop();';"> <tr> <th>Nom</th> <th>Prénom</th> <th>Adresse</th> <th>Code Postal</th> <th>Ville</th> <th>Téléphone</th> <th>Portable</th> <th>E-Mail</th> <th>Sélection</th> <th>Supprimer</td> </tr> <?php while ($row=$res->fetch(PDO::FETCH_OBJ)){?> <tr> <td><a href="javascript:PopupWindow(this,'../formulaire/client.form.modifier.php?client_id=<?php echo $row->Num_Client?>');"><?php echo $row->Nom_Client?></a></td> <td><?php echo "$row->Prenom_Client"?></td> <td><?php echo "$row->Adresse_Client"?></td> <td><?php echo "$row->CP_Client"?></td> <td><?php echo "$row->Ville_Client"?></td> <td><?php echo "$row->Telephone_Client"?></td> <td><?php echo "$row->Portable_Client"?></td> <td><?php echo "$row->Mail_Client"?></td> <td><input type="checkbox" name="del[]" value="<?php echo $row->Num_Client?>" class="del" id="del"/> </td> <td><a href="../include/supprimer_client.php?client_id=<?php echo $row->Num_Client?>">Supprimer ce client</a></td> </tr> <?php }?> </table> </form> </body> </html>
2ème problèmes :
-Quand j'ajoute une fiche client, l'ajout se déroule bien mais la date dans le tableau reste à 00/00/0000;
-Quand à la modification, elle ne marche pas du tout sans message d'erreur.
fiche.php :
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74 <body> <?php include "../include/fonctions.php"; $connex = connexion_bd(); $req="SELECT Num_Fiche, TypeMateriel, DATE_FORMAT(Date_Arrivee,'%d/%m/%Y') AS Date_Arrivee, Mot_de_Passe, Etat, Description, Accessoire, client.Num_Client, client.Nom_Client, client.Prenom_Client FROM fiche INNER JOIN client ON client.Num_Client=fiche.Num_Client"; $res=$connex->query($req); $donnees=""; if(isset($_POST['delete'])){ if (isset($_POST['del'])){ if(count($_POST['del']) >=1){ $connex->exec('DELETE FROM fiche WHERE Num_Fiche IN (' . implode(', ', array_map('intval', $_POST['del'])) . ')'); header("Location:fiche.php"); } } else{ } } ?> <form method='POST' action='fiche.php'> <table> <input type="submit" name="delete" id="delete" class="delete" value="Supprimer la sélection"> <input type="button" value="Ajouter une fiche" onclick="location.href='javascript:ajoutfichepop();';"> <tr> <th>Numéro client</th> <th>Nom client</th> <th>Prénom client</th> <th>Type matériel</th> <th>Date arrivée</th> <th>Mot de passe</th> <th>Etat</th> <th>Accessoire(s)</th> <th>Description</th> <th>Sélection</th> <th>Supprimer</th> </tr> <?php while ($row=$res->fetch(PDO::FETCH_OBJ)){?> <tr> <td><?php echo "$row->Num_Client"?></td> <td><a href="javascript:PopupWindow(this,'../formulaire/fiche.form.modifier.php?fiche_id=<?php echo $row->Num_Fiche?>');"><?php echo $row->Nom_Client?></a></td> <td><?php echo "$row->Prenom_Client"?></td> <td><?php echo "$row->TypeMateriel"?></td> <td><?php echo "$row->Date_Arrivee"?></td> <td><?php echo "$row->Mot_de_Passe"?></td> <td><?php if ($row->Etat==0) {?><img src="../image/orange-loading.gif"> <?php } else { ?><img src="../image/validation-2.png"> <?php } ?></td> <td><?php echo "$row->Accessoire"?></td> <td><?php echo "$row->Description"?></td> <td><input type="checkbox" name="del[]" value="<?php echo $row->Num_Fiche?>" class="del" id="del"/> </td> <td><a href="../include/supprimer_fiche.php?fiche_id=<?php echo $row->Num_Fiche?>">Supprimer cette fiche</a></td> </tr> <?php }?> </table> </form> </body> </html> </body>
fiche.form.modifier.php :
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68 <!DOCTYPE html> <html> <head> <title>Modifier une fiche</title> </head> <body onunload="window.opener.location.reload(true);"> <?php include "../include/fonctions.php"; $connex = connexion_bd(); $reqcat="SELECT * FROM client"; $rescat= $connex->query($reqcat); $req="SELECT Num_Fiche, TypeMateriel, DATE_FORMAT(Date_Arrivee,'%d/%m/%Y') AS Date_Arrivee, Mot_de_Passe, Etat, Description, Accessoire, client.Num_Client, client.Nom_Client, client.Prenom_Client FROM fiche INNER JOIN client ON client.Num_Client=fiche.Num_Client WHERE Num_Fiche=?"; $prep=$connex->prepare($req); $prep->bindValue(1, $_GET["fiche_id"]); $prep->execute(); $row=$prep->fetch(PDO::FETCH_OBJ); if(isset($_POST['envoyer'])) { $req="UPDATE fiche SET TypeMateriel=?, Date_Arrivee=?, Mot_de_Passe=?, Etat=?, Description=?, Accessoire=?, Num_Client=? WHERE Num_Client=?"; $prep=$connex->prepare($req); $prep->bindValue(1, $_POST['TypeMateriel']); $prep->bindValue(2, $_POST['Date_Arrivee']); $prep->bindValue(3, $_POST['Mot_de_Passe']); $prep->bindValue(4, $_POST['Etat']); $prep->bindValue(5, $_POST['Description']); $prep->bindValue(6, $_POST['Accessoire']); $prep->bindValue(7, $_POST['Num_Client']); $prep->bindValue(8, $_GET['fiche_id']); $prep->execute(); } ?> <form name="modifier" method="post" action=""> <legend><b><i>Modifier une fiche</i></b></legend> <p>Type de matériel : <input value="<?php echo $row->TypeMateriel;?>" name="TypeMateriel" id="modifie"></p> <p>Date d'arrivée : <input value="<?php echo $row->Date_Arrivee;?>" name="Date_Arrivee" id="modifie"></p> <p>Mot de passe : <input value="<?php echo $row->Mot_de_Passe;?>" name="Mot_de_Passe" id="modifie"></p> <p>Etat :<input value="<?php echo $row->Etat;?>" name="Etat" id="modifie"></p> <p>Description :<input value="<?php echo $row->Description;?>" name="Description" id="modifie"></p> <p>Accessoire :<input value="<?php echo $row->Accessoire;?>" name="Accessoire" id="modifie"></p> <p>Client : <SELECT name="Num_Client" id="modifie"> <?php while($rowcat=$rescat->fetch(PDO::FETCH_OBJ)){ $selected=""; if($row->Nom_Client==$rowcat->Nom_Client){ $selected="selected=''"; }?> <OPTION <?php echo $selected; ?> value="<?php echo $rowcat->Num_Client?>"><?php echo $rowcat->Nom_Client; echo " "; echo $rowcat->Prenom_Client;?></OPTION> <?php } ?></SELECT></p> <input type="submit" name="envoyer" id="bouton" value="Envoyer"> </form> </body> </html>
fiche.form.ajouter.php :
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
55 <!DOCTYPE html> <html> <head> </head> <body onload="javascript:parent.opener.location.reload();"><?php include "../include/fonctions.php"; $connex = connexion_bd(); $reqcat="SELECT * FROM client"; $rescat= $connex->query($reqcat); $date = date("d-m-Y"); if(isset($_POST['envoyer'])) { $req="INSERT INTO FICHE (TypeMateriel, Date_Arrivee, Mot_de_Passe, Etat, Description, Accessoire, Num_Client) VALUES (?, ?, ?, ?, ?, ?, ?)"; $prep=$connex->prepare($req); $prep->bindValue(1, $_POST['TypeMateriel']); $prep->bindValue(2, $_POST['Date_Arrivee']); $prep->bindValue(3, $_POST['Mot_de_Passe']); $prep->bindValue(4, $_POST['Etat']); $prep->bindValue(5, $_POST['Description']); $prep->bindValue(6, $_POST['Accessoire']); $prep->bindValue(7, $_POST['Num_Client']); $prep->execute(); header("Location:../formulaire/fiche.form.ajouter.php"); } ?> <form method='POST' action='fiche.form.ajouter.php'> <p>Type Materiel : <input name="TypeMateriel" type="text" size="30"/></p> <p>Date_Arrivee : <input name="Date_Arrivee" type="text" size="30" value="<?php echo $date?>"/></p> <p>Mot_de_Passe : <input name="Mot_de_Passe" type="text" size="30"/></p> <p>Etat : <input name="Etat" type="text" size="30"/></p> <p>Description : <input name="Description" type="text" size="30"/></p> <p>Accessoire(s) : <input name="Accessoire" type="text" size="30"/></p> <p>Client : <SELECT name="Num_Client" id="ajout"> <?php while($rowcat=$rescat->fetch(PDO::FETCH_OBJ)){ $selected=""; if($row->Nom_Client==$rowcat->Nom_Client){ $selected="selected=''"; }?> <OPTION <?php echo $selected; ?> value="<?php echo $rowcat->Num_Client?>"><?php echo $rowcat->Nom_Client; echo " "; echo $rowcat->Prenom_Client;?></OPTION> <?php } ?></SELECT></p></p> <input type="submit" name="envoyer" id="bouton" value="Ajouter la fiche"> <input type="reset" name="buttonAnnuler" value="Effacer"> </form> <input type="button" value="Fermer la fenêtre" onclick="javascript:parent.opener.location.reload();window.close();"> </body> </html>
Je sais que c'est très gros comme post mais je pense que vous aurez besoin de tout sa pour m'aider sinon dites moi si j'en est trop mis ! Merci beaucoup de l'aide apportée d'avance, je suis pas très fort en développement donc votre aide sera très précieuse Bonne journée !
Partager