Bonjour, j'aimerais avoir une aide, j'ai créé deux formulaires dont l'un pour saisir les données et l'autre pour les afficher, le problème est que les données saisies ne s'enregistrent pas dans la base de données et ne s'affichent pas dans le deuxième formulaire. Voici le code de deux fichiers.
<?php
session_start();
if (empty($_SESSION['id']) || !isset($_SESSION['id'])) {
header('location:index_gestion.php?msg=1');
# code...
}
require_once('cn.php');
$re=$cn->query('SELECT * FROM etudiant');
?>
<!DOCTYPE html>
<html>
<head>
<title>Inscription</title>
<link rel="stylesheet" type="text/css" href="css/bootstrap.css">
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/bootstrap.js"></script>
</head>
<body>
<div class="container-fluid">
<div class="row"><br><br>
<div class="col-md-3">
<?php if (isset($_GET['msg'])) { ?>
<?php if ($_GET['msg']==2) { ?>
<div class="alert alert-success alert dismissable">
<button type="button" class="close" data-dismiss="alert" aria-hidden="true"> × </button>Enregistrement effectue avec succes
</div>
<?php } ?>
<?php } ?>
<div class="panel panel-primary">
<div class="panel-heading">
<div align="center"><i class="glyphicon glyphicon-pencil"></i> Inscription</div>
</div>
<div class="panel-body">
<form class="form-horizontal" action="opera_gest.php" method="POST" enctype="multipart/form-data"><br>
<!--masquage de civilite-->
<input type="hidden" name="c" value="0">
<input type="hidden" name="civilite" value="<?php echo $tabRe['civilite']; ?>">
<input type="hidden" name="ide" value="<?php echo$tabRe['ide']; ?>">
<div class="input-group"><span class="input-group-addon" id="sizing-addon1"></span>
<select class="form-control" name="civilite">
<option value="" selected="selected">Civilite</option>
<option value="H">Mr</option>
<option value="F">Mme</option>
</select>
</div><br>
<div class="input-group">
<span class="input-group-addon" id="sizing-addon1"></span>
<input type="text" name="nom" class="form-control" placeholder="nom" required>
</div><br>
<div class="input-group"><span class="input-group-addon" id="sizing-addon1"></span>
<input type="text" name="prenom" class="form-control" placeholder="prenom" required>
</div><br>
<div class="input-group"><span class="input-group-addon" id="sizing-addon1"><i class="glyphicon glyphicon-pencil"></i></span>
<textarea name="adress" cols="5" rows="4" class="form-control" placeholder="Adresse"></textarea>
</div><br>
<div class="input-group"><span class="input-group-addon" id="sizing-addon1"><i class="glyphicon glyphicon-home"></i></span>
<input type="text" name="ville" class="form-control" placeholder="Saisir ville">
</div><br>
<div class="input-group"><span class="input-group-addon" id="sizing-addon1"></span>
<select class="form-control" name="pays"><option value="" selected="selected">Pays</option>
<option value="Niger">Niger</option>
<option value="Benin">Benin</option>
<option value="Togo">Togo</option>
<option value="Burkina">Burkina</option>
<option value="Mali">Mali</option>
</select></div><br>
<div class="input-group"><span class="input-group-addon" id="sizing-addon1"><i class="glyphicon glyphicon-earphone"></i></span><input type="text" name="" class="form-control" placeholder="saisir le numero de telephone" required>
</div><br>
<div class="input-group"><span class="input-group-addon" id="sizing-addon1">@</span><input type="text" name="" class="form-control" placeholder="saisir l'adresse mail" required>
</div><br>
<div class="input-group"><span class="input-group-addon" id="sizing-addon1"></span>
<select class="form-control" name="">
<option value="" selected="selected">Niveau academique actuel</option>
<option value="BTS">BTS</option>
<option value="Licence">Licence</option>
<option value="Master">Master</option>
</select></div><br>
<div class="input-group"><span class="input-group-addon" id="sizing-addon1"></span>
<select class="form-control" name="departement">
<option value="" selected="selected">Departement</option>
<option value="">Lettre moderne</option>
<option value="">Histoire</option>
<option value="">Geographie</option>
</select></div><br>
<div class="input-group"><span class="input-group-addon" id="sizing-addon1"></span>
<select class="form-control" name="">
<option value="" selected="selected">Filiere</option>
<option value="">Philo</option>
<option value="">lettre</option>
<option value="">Histoire</option>
</select></div><br>
<div class="input-group"><span class="input-group-addon" id="sizing-addon1"></span>
<select class="form-control" name=""><option value="" selected="selected">Formation souhaitee</option>
<option value="BTS">BTS</option>
<option value="Licence">Licence</option>
<option value="Master">Master</option>
<option value="Doctorat">Doctorat</option>
</select></div><br>
<div class="input-group"><span class="input-group-addon" id="sizing-addon1"><i class="glyphicon glyphicon-pencil"></i></span>
<textarea name="message" class="form-control" placeholder="Message" cols="5" rows="4"></textarea>
</div>
<div class="checkbox">
<label><input type="checkbox" name="ok" class="checkbox" value="ok"> J'accepte le contrat d'etude</label>
</div>
<div class="form-group">
<label for="inputfile"></label>
<input type="file" id="inputfile">
</div>
<button type="reset" class="btn btn-danger btn-block"><span class="glyphicon glyphicon-remove"></span> Annuler
</button>
<button type="submit" class="btn btn-primary btn-block"><span class="glyphicon glyphicon-ok"></span> Inscrire</button>
</form>
</div>
</div>
</div>
<div class="col-md-8">
<table class="table table-bordered table-striped table-hover">
<thead>
<tr class="info">
<th>Nom et prenom</th>
<th>Niveau</th>
<th>Formation</th>
<th>Tel</th>
<th>Email</th>
<th>Menu</th>
</tr>
</thead>
<tbody>
<tr>
<?php while ($tabRe=$re->fetch()) {?>
<td><?php echo $tabRe['nom'].' '.$tabRe['prenom']; ?></td>
<td><?php echo $tabRe['niveau']; ?></td>
<td><?php echo $tabRe['formation']; ?></td>
<td><?php echo $tabRe['tel']; ?></td>
<td><?php echo $tabRe['email']; ?></td>
<td>
<button class="glyphicon glyphicon-pushpin btn btn-warning"></button>
<button class="glyphicon glyphicon-thumbs-down btn btn-danger"></button>
<button class="glyphicon glyphicon-thumbs-up btn btn-success"></button>
</td>
</tr>
<?php } ?>
</form>
</tbody>
</table>
</div>
</div>
</div>
</body>
</html>
session_start();
if(empty($_SESSION['id']) || !isset($_SESSION['id'])) {
header('location:index_gestion.php');
}
//inclusion du fichier de connexion
require_once('cn.php');
extract($_POST);
//Preparation de la requete pour charger le formulaire
if($_POST['c']==0){
$ins=$cn->prepare('INSERT INTO etudiant(nom,prenom,niveau,formation,tel,email,) VALUES(?,?,?,?,?,?)');
$ins->execute([$nom,$prenom,$niveau,$formation,$tel,$email]);
header("location:ins_gestion.php?msg=2");
}elseif($_POST['c']==1){
$ins=$cn->prepare('UPDATE client SET nom=?,prenom=?,niveau=?,formation=?,tel=?,email=? WHERE ide=?');
$ins->execute([$nom,$prenom,$niveau,$formation,$tel,$email]);
header('location:ins_gestion.php');
}
?>
Afficher la suite