Bonjour ;
je suis débutant au développement avec php mysql j'ai besoin de ton aide sur l'ajout de nouveaux élevé voici fichier ajouté contient :
1- fichier ajout.php:
2- fichier ajout_etudaint.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 <?php require_once('Conextion/connect.php'); ?> <?php if(isset($_POST['id_eleve'])) $a1 = $_POST['id_eleve']; else $id_eleve=""; if(isset($_POST['Nom_etudaint'])) $a2 = $_POST['Nom_etudaint']; else $Nom_etudaint=""; if(isset($_POST['Prenom_etudiant'])) $a3 = $_POST['Prenom_etudiant']; else $Prenom_etudiant=""; if(isset($_POST['date_naissance'])) $a4 = $_POST['date_naissance']; else $date_naissance=""; if(isset($_POST['lieu_naissance'])) $a5 = $_POST['lieu_naissance']; else $lieu_naissance=""; if(isset($_POST['classe'])) $a6 = $_POST['classe']; else $classe=""; if(isset($_POST['numero_telephone'])) $a7 = $_POST['numero_telephone']; else $numero_telephone=""; if(empty($id_eleve) OR empty($Nom_etudaint) OR empty($Prenom_etudiant) OR empty($date_naissance) OR empty($lieu_naissance)OR empty($classe)OR empty($numero_telephone)) { echo ' <a href="javascript:history.go(-1)"><h1 align="center"><font color="red">Attention,reste des champs vide !</font></h1></a>'; } // Aucun champ n'est vide, on peut enregistrer dans la table else { // on écrit la requête sql mysql_select_db($database_connect, $connect); $sql="INSERT INTO `eleve`('id_eleve','nom','prenom','num_telephone','classe','date_naissance','lieu_naissance')" ; // on insère les informations du formulaire dans la table mysql_query($sql) or die('Erreur SQL !'.$sql.'<br>'.mysql_error()); header('Location: ajoute_etudiant.php'); mysql_close(); // on ferme la connexion ?>
problème ne ajout pas au bd et n'affiche aucun erreur
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<?php require_once('Conextion/connect.php'); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>ajouté eleve</title> </head> <body> <h3> ajouté un nouveaux éléve </h3> <table width="476" height="356" border="1"> <tr> <th width="221" scope="row">Numero d'inscription</th> <td width="239"><input name="a1" type="" id="id_eleve" maxlength="10" class="backgroundTextField"/></td> </tr> <tr> <th scope="row">Nom étudaint(e)</th> <td><input name="a2" type="" id="Nom_etudaint" maxlength="10" class="backgroundTextField"/></td> </tr> <tr> <th scope="row">Prénom étudiant(e)</th> <td><input name="a3" type="" id="Prenom_etudiant" maxlength="10" class="backgroundTextField"/></td> </tr> <tr> <th scope="row">date naissance</th> <td><input name="a4" type="" id="date naissance" maxlength="10" class="backgroundTextField"/></td> </tr> <tr> <th scope="row">lieu naissance</th> <td><input name="a5" type="" id="lieu naissance" maxlength="10" class="backgroundTextField"/></td> </tr> <tr> <th scope="row">classe</th> <td><input name="a6" type="" id="classe" maxlength="10" class="backgroundTextField"/></td> </tr> <tr> <th scope="row">numero telephone </th> <td><input name="a7" id="numero telephone" maxlength="10" class="backgroundTextField"/></td> </tr> </table> <td><input type="submit" name="ajouter" value="Ajouter"/></td> </body> </html>
Partager