Bonjour,
je suis en train de programmé un formulaire d'inscription sur PhpStorm pour une inscription d'étudiants, et j'ai un problème de connexion avec l'insertion des données dans ma base qui ne reçoit rien.
Tandis que PhpStorm lui me met aucune erreur et de même pour la console web, je mets ci-dessous le code du formulaire de vérification et la classe PHP Database qui sont les deux fichiers en lien avec cette connexion.
-vérification.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 <!DOCTYPE html> <html lang="fr" > <meta charset="UTF-8"> <head> <title>Inscription</title> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/meyer-reset/2.0/reset.min.css"> <link rel="stylesheet" href="../css/style.css"> <link rel="prefetch" href="../upload.php"> </head> <body> <!-- multistep form --> <form id="msform" method="post" > <!-- progressbar --> <ul id="progressbar"> <li class="active">Données Personnelles</li> <li class="active">EMail & Formation</li> <li class="active">Adresse physique</li> <li class="active">Photo</li> <li class="active">Vérification</li> </ul> <fieldset> <h2 class="fs-title">Dernière étape</h2> <h3 class="fs-subtitle">Vérifier vos données.</h3> <?php /*fieldset 5*/ echo '<table>'; echo '<tr>'; echo '<td>Nom de naissance : </td><td>'; if(isset($_POST['Nom_Naiss'])){$nom_naiss = $_POST['Nom_Naiss']; echo strtoupper($nom_naiss);};'</td></tr>'; echo '<tr>', '<td>Nom usuel : </td><td> '; if(isset($_POST['Nom_Usage'])){$nom_usage = strtoupper($_POST['Nom_Usage']); echo $nom_usage;};'</td></tr>'; echo '<tr>', '<td>Prenom : </td><td>'; if(isset($_POST['Prenom'])){$prenom = $_POST['Prenom']; echo strtolower($prenom);};'</td></tr>'; echo '<tr>', '<td>Autres prénoms : </td><td>'; if(isset($_POST['Autres_Prenoms'])){$autres_prenoms = $_POST['Autres_Prenoms']; echo strtolower($autres_prenoms);};'</td></tr>'; echo '<tr>', '<td>Date de naissance : </td><td>'; if(isset($_POST['Date_Naiss'])){$date_naiss = $_POST['Date_Naiss']; echo $date_naiss;};'</td></tr>'; echo '<tr>', '<td>Adresse Mail : </td><td>'; if(isset($_POST['Mail'])){$mail = $_POST['Mail']; echo $mail;};'</td></tr>'; echo '<tr>', '<td>Formation : </td><td>'; if(isset($_POST['Formation'])){$formation = $_POST['Formation']; echo $formation;};'</td></tr>'; echo '<tr>', '<td>Adresse 1 : </td><td>'; if(isset($_POST['Adr1'])){$adr1 = $_POST['Adr1']; echo $adr1;};'</td></tr>'; echo '<tr>', '<td>Adresse 2 : </td><td>'; if(isset($_POST['Adr2'])){$adr2 = $_POST['Adr2']; echo $adr2;};'</td></tr>'; echo '<tr>', '<td>Code postal : </td><td>'; if(isset($_POST['CP'])){$cp = $_POST['CP']; echo $cp;};'</td></tr>'; echo '<tr>', '<td>Ville : </td><td>'; if(isset($_POST['Ville'])){$ville = $_POST['Ville']; echo $ville;};'</td></tr>'; echo '<tr>', '<td>Téléphone : </td><td>'; if(isset($_POST['Tel'])){$tel = $_POST['Tel']; echo $tel;};'</td></tr>'; echo '<tr>', '<td>Téléphone portable : </td><td>'; if(isset($_POST['TelPortable'])){$telportable = $_POST['TelPortable']; echo $telportable;};'</td></tr>'; echo '</table>'; require_once './database.php'; function insertstud(){ $bdd = new database(); $bdd -> conn(); $nom_naiss=''; $nom_usage=''; $prenom=''; $autres_prenoms=''; $date_naiss=DateTimeInterface::RFC850; $mail=''; $formation=''; $adr1=''; $adr2=''; $cp=''; $ville=''; $tel=''; $telportable=''; if(isset($_POST['Nom_Naiss'])){$nom_naiss = strtoupper($_POST['Nom_Naiss']);} if(isset($_POST['Nom_Usage'])){$nom_usage = strtoupper($_POST['Nom_Usage']);} if(isset($_POST['Prenom'])){$prenom = strtolower($_POST['Prenom']);} if(isset($_POST['Autres_Prenoms'])){$autres_prenoms = strtolower($_POST['Autres_Prenoms']);} if(isset($_POST['Date_Naiss'])){$date_naiss = $_POST['Date_Naiss'];} if(isset($_POST['Mail'])){$mail = $_POST['Mail'];} if(isset($_POST['Formation'])){$formation = $_POST['Formation'];} if(isset($_POST['Adr1'])){$adr1 = $_POST['Adr1'];} if(isset($_POST['Adr2'])){$adr2 = $_POST['Adr2'];} if(isset($_POST['CP'])){$cp = $_POST['CP'];} if(isset($_POST['Ville'])){$ville = $_POST['Ville'];} if(isset($_POST['Tel'])){$tel = $_POST['Tel'];} if(isset($_POST['TelPortable'])){$telportable = $_POST['TelPortable'];} $query= $bdd->getBdd()->prepare($bdd->addstud()); $array=array( 'Nom_Naiss' => $nom_naiss, 'Nom_Usage' => $nom_usage, 'Prenom' => $prenom, 'Autres_Prenoms' => $autres_prenoms, 'Date_Naiss' => $date_naiss, 'Mail' => $mail, 'Formation' => $formation, 'Adr1' => $adr1, 'Adr2' => $adr2, 'CP' => $cp, 'Ville' => $ville, 'Tel' => $tel, 'TelPortable' => $telportable ); $query->execute($array); } if(isset($_POST['submit'])){ insertstud(); header('Location: ../index.php'); } if(isset($_POST['prev'])){ header('Location: ../index.php'); } ?> <input type="submit" name="prev" class="previous action-button" value="Recommencer" /> <input type="submit" name="submit" class="submit action-button" value="Submit" /> <?php ?> </fieldset> <script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script> <script src='http://cdnjs.cloudflare.com/ajax/libs/jquery-easing/1.3/jquery.easing.min.js'></script> </form> </body> </html>
et database.php:
Je ne vois vraiment plus quoi faire après avoir tester de multiples méthodes pour l'insertion, cela me serait d'une grande aide de recevoir une solution.
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 <?php class database { private $_host = 'mysql:host=localhost:3306;dbname=inscription'; private $_login = 'root'; private $_password = ''; private $_bdd; /** * @return string */ public function getHost(): string { return $this->_host; } /** * @param string $host */ public function setHost(string $host): void { $this->_host = $host; } /** * @return string */ public function getLogin(): string { return $this->_login; } /** * @param string $login */ public function setLogin(string $login): void { $this->_login = $login; } /** * @return string */ public function getPassword(): string { return $this->_password; } /** * @param string $password */ public function setPassword(string $password): void { $this->_password = $password; } /** * @return mixed */ public function getBdd() { return $this->_bdd; } /** * @param mixed $bdd */ public function setBdd($bdd): void { $this->_bdd = $bdd; } function conn() { try { $this->setBdd(new PDO($this->getHost(),$this->getLogin(),$this->getPassword())); } catch (PDOException $exception) { printf("Connection error: %s", $exception->getMessage()); } } function addstud(){ return ('INSERT INTO etudiant(Nom_Naiss,Nom_Usage, Prenom,Autres_Prenoms, Mail, Formation, Date_Naiss, Adr1, Adr2, CdePostal, Ville, Tel, Tel_Portable)VALUES ($nom_naiss, $nom_usage, $prenom, $autres_prenoms, $mail, $formation, $date_naiss, $adr1, $adr2, $cp, $ville, $tel, $telportable)'); } };
En vous remerciant d'avance pour votre aide.
Partager