Bonsoir ,
je vous présente mon soucis :
j'ai une page à protégée ( m15g2.php ) jusque là tout va bien .
A l'intérieur de cette page j'ai plusieurs forms qui me permettent d'enregistrer ou d'ajouter des lignes (enregistrement.php) . Mais à la fin de chacun de ces forms ,
j'ai une ligne :
qui me permet , après l’exécution du code (contenue dans enregistrement.php) de renvoyer vers m15g2.php
Code : Sélectionner tout - Visualiser dans une fenêtre à part header('Location: /php/m15g2.php');
Le soucis étant que je dois retaper le mot de passe à chaque fois puisque je reviens sur la page "mdp.php"...
Avez vous une idée d'une démarche à prendre pour résoudre le pb ?
Voici les codes:
m15g2.php
mdp.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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167 <!DOCTYPE html> <?php error_reporting(E_ALL); try { $bdd = new PDO('mysql:host=localhost; dbname=******', '****', '*****'); } catch (Exception $e) { die('Erreur : ' . $e->getMessage()); } ?> <html> <head> <meta charset="utf-8" /> <link rel="stylesheet" type="text/css" href="style2.css" /> <link rel="icon" href="icone.ico" /> <title>Planning de l'équipe -15 Garçons 2</title> <style type = "text"> color:white; text-align: center; background-color:#202020" </style> </head> <body> <?php if (isset($_POST['mot_de_passe']) AND $_POST['mot_de_passe'] == "kangourou") // Si le mot de passe est bon { // On affiche les codes ?> <h2 id="m15g2">Planning de l'équipe -15 Garcons 2 </h2> <style> table{border-collapse: collapse;border:1px solid black;}td{border: 1px solid black;width:65px;height:30px;text-aligne:center;} input{border: 0px; outline: 0} </style> <?php $reponse = $bdd->query('SELECT * FROM tableau'); // Affichage du tableau ?> <form action="/enregistrement/enregistrer.php" method="post"> <table id="tableau"> <thead> <tr> <th>Matchs</th> <th>Date</th> <th>Locaux</th> <th>Visiteurs</th> <th>Maillots</th> <th>Voiture 1</th> <th>Voiture 2</th> <th>Voiture 3</th> <th>Voiture 4</th> <th>Gateau et boissons 1</th> <th>Gateau et boissons 2</th> <th>Buvette</th> </tr> </thead> <tbody> <?php while ($donnees = $reponse->fetch()) { ?> <?php $date = date($donnees['date']);?> <tr> <td><?php echo $donnees['ID']?></td> <td><input type="date" style="color:white;text-align: center;background-color:#202020" name="date[<?php echo $donnees['ID']?>]" value= "<?php echo $date ?>" ></td> <td><input type="text" style="color:white;text-align: center;background-color:#202020" name="locaux[<?php echo $donnees['ID']?>]" value="<?php echo $donnees['locaux'];?>" ></td> <td><input type="text" style="color:white;text-align: center;background-color:#202020" name="visiteurs[<?php echo $donnees['ID']?>]" value="<?php echo $donnees['visiteurs'];?>" ></td> <td><input type="text" style="color:white;text-align: center;background-color:#202020" name="maillots[<?php echo $donnees['ID']?>]" value="<?php echo $donnees['maillots'];?>" ></td> <td><input type="text" style="color:white;text-align: center;background-color:#202020" name="voiture1[<?php echo $donnees['ID']?>]" value="<?php echo $donnees['voiture1'];?>" ></td> <td><input type="text" style="color:white;text-align: center;background-color:#202020" name="voiture2[<?php echo $donnees['ID']?>]" value="<?php echo $donnees['voiture2'];?>" ></td> <td><input type="text" style="color:white;text-align: center;background-color:#202020" name="voiture3[<?php echo $donnees['ID']?>]" value="<?php echo $donnees['voiture3'];?>" ></td> <td><input type="text" style="color:white;text-align: center;background-color:#202020" name="voiture4[<?php echo $donnees['ID']?>]" value="<?php echo $donnees['voiture4'];?>" ></td> <td><input type="text" style="color:white;text-align: center;background-color:#202020" name="gateau1[<?php echo $donnees['ID']?>]" value="<?php echo $donnees['gateau1'];?>" ></td> <td><input type="text" style="color:white;text-align: center;background-color:#202020" name="gateau2[<?php echo $donnees['ID']?>]" value="<?php echo $donnees['gateau2'];?>" ></td> <td><input type="text" style="color:white;text-align: center;background-color:#202020" name="buvette[<?php echo $donnees['ID']?>]" value="<?php echo $donnees['buvette'];?>" ></td> </tr> <?php } ?> </tbody> </table> <div style="float: left ; margin-left: 54px"> <input type="submit" style = "padding: 10px 24px;background:#202020;color:yellow;" value="Enregistrer" /> </form> </div> <div style="float: left ; margin-left: 30px"> <form action="/enregistrement/newligne.php" method="post"> <input type="submit" style = "padding: 10px 24px;background:#202020;color:yellow;" value="Nouveau Match" /> </form> </div> <h2 id="m15g2" ; style="padding-top:40px">Contacts de l'équipe -15 Garcons 2 </h2> <?php $reponse = $bdd->query('SELECT * FROM contacts'); // Affichage du tableau ?> <form action="/enregistrement/enregistrercontact.php" method="post"> <table id="contacts"> <thead> <tr> <th> </th> <th>Noms</th> <th>Prénoms</th> <th>Num</th> <th>Adresse mail</th> </tr> </thead> <tbody> <?php while ($donnees = $reponse->fetch()) { ?> <tr> <td><?php echo $donnees['ID']?></td> <td><input type="nom" style="color:white;text-align: center;background-color:#202020" name="nom[<?php echo $donnees['ID']?>]" value= "<?php echo $donnees['nom'];?>" ></td> <td><input type="prenom" style="color:white;text-align: center;background-color:#202020" name="prenom[<?php echo $donnees['ID']?>]" value="<?php echo $donnees['prenom'];?>" ></td> <td><input type="num" style="color:white;text-align: center;background-color:#202020" name="num[<?php echo $donnees['ID']?>]" value="<?php echo $donnees['num'];?>" ></td> <td><input type="mail" style="color:white;text-align: center;background-color:#202020" name="mail[<?php echo $donnees['ID']?>]" value="<?php echo $donnees['mail'];?>" ></td> </tr> <?php } ?> </tbody> </table> <div style="float: left ; margin-left: 54px"> <input type="submit" style = "padding: 10px 24px;background:#202020;color:yellow;" value="Enregistrer" /> </form> </div> <div style="float: left ; margin-left: 30px"> <form action="/enregistrement/newlignecontact.php" method="post"> <input type="submit" style = "padding: 10px 24px;background:#202020;color:yellow;" value="Nouveau Contact" /> </form> </div> <?php //fermerture de la base. if ($bdd) { $bdd = NULL; } ?> <h2 id="m15g2" ; style="padding-top:40px"></h2> <?php } else // Sinon, on affiche un message d'erreur { echo '<p>Mot de passe incorrect</p>'; } ?> </body> </html>
et enregistrement.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 <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title>Page protégée par mot de passe</title> <link rel="stylesheet" type="text/css" href="style2.css" /> <link rel="icon" href="icone.ico" /> </head> <body> <p>Veuillez entrer le mot de passe</p> <form action="m15g2.php" method="post"> <p> <input type="password" style="color:black;text-align: left;background-color:#202020 border-collapse: collapse;border:0px solid black;" name="mot_de_passe" /> <input type="submit" style = "padding: 10px 24px;background:#202020;color:yellow; border-collapse: collapse;border:0px solid black;" value="Valider" /> </p> </form> </body> </html>
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 <?php // Connexion à la base de données try { $bdd = new PDO('mysql:host=localhost; dbname=******', '****', '*****'); } catch(Exception $e) { die('Erreur : '.$e->getMessage()); } // Insertion du message à l'aide d'une requête préparé $sql = "UPDATE tableau SET date = :date, locaux = :locaux, visiteurs = :visiteurs, maillots = :maillots, voiture1 = :voiture1, voiture2 = :voiture2, voiture3 = :voiture3, voiture4 = :voiture4, gateau1 = :gateau1, gateau2 = :gateau2, buvette = :buvette WHERE ID = :ID"; $req = $bdd->prepare($sql); foreach( $_POST['date'] as $ID => $date ) { $req->execute(array( ':date' => $_POST['date'][$ID], ':locaux' => $_POST['locaux'][$ID], ':visiteurs' => $_POST['visiteurs'][$ID], ':maillots' => $_POST['maillots'][$ID], ':voiture1' => $_POST['voiture1'][$ID], ':voiture2' => $_POST['voiture2'][$ID], ':voiture3' => $_POST['voiture3'][$ID], ':voiture4' => $_POST['voiture4'][$ID], ':gateau1' => $_POST['gateau1'][$ID], ':gateau2' => $_POST['gateau2'][$ID], ':buvette' => $_POST['buvette'][$ID], ':ID' => $ID // en dernier : pas de virgule) )); }// Redirection du visiteur vers la page du minichat header('Location: /php/m15g2.php'); ?>
Partager