Bonjour,
je n'arrive pas à insérer les données de mon formulaire dans ma base de donnée.
La requête s'exécute sans erreur mais aucune donnée n'est insérée dans la base de données.
Voici mes codes:

FORMULAIRE HTML


<form class="form-horizontal well .well-md" name="add_user" method="post" action="cadd_user.php">
  
<div class="form-group">
    <label class="col-md-3 control-label" for="namuse">
      Last name
    </label>
    <div class="col-md-9">
      <input class="form-control" id="nameuse" name="nom_use" type="text" required="true" autofocus="true">
    </div>
  </div>
  
  
  <div class="form-group">
    <label class="col-md-3 control-label" for="preuse">
      First name
    </label>
    <div class="col-md-9">
	 <input class="form-control" id="preuse" name="pre_use" type="text" required="true">
    </div>
  </div>

  

  <div class="form-group">
    <label class="col-md-3 control-label" for="loguse">
      Login
    </label>
    <div class="col-md-9">
      <input class="form-control" id="loguse" name="log_in" type="text" required="true" onfocus="concatener()">
    </div>
  </div>
  
   <div class="form-group">
    <label class="col-md-3 control-label" for="passuse">
      Password
    </label>
    <div class="col-md-9">
      <input class="form-control" id="passuse" name="pwd_use" type="password" readonly="true" pattern=".{6,15}" value="password">
    </div>
  </div>
  
     
    <div class="form-group">
    <label class="col-md-3 control-label" for="roleuse">
      Role
    </label>
    <div class="col-md-9">
	 <select name="rol_use" id="roleuse" required="true">
      <option value="">- - -   Please choose an option   - - -</option>
      <option value="ADMINISTRATOR">ADMINISTRATOR</option>
      <option value="SUPER USER">SUPER USER</option>
      <option value="MANAGER">MANAGER</option>
      <option value="CONTROLLER">CONTROLLER</option>
      <option value="OPERATIONAL">OPERATIONAL</option>
	 </select>
    </div>
  </div> 
  
  <div class="form-group">
    <label class="col-md-3 control-label" for="email">
      Email
    </label>
    <div class="col-md-9">
	 <input class="form-control" id="email" name="ema_use" type="text" required="true" onfocus="concatener2()">
    </div>
  </div>
   
  
     
  <div class="row col-md-offset-5">
   
   <div class="col-md-3">  
    <button class="btn btn-primary" onClick="location.replace('.$page_home.');">Cancel</button>   
   </div>
   
   <div class="col-md-3 col-md-offset-1">  
    <input class="btn btn-primary" type="submit" value="Save">  
   </div>
   
  </div>  
</form>


SCRIPT PHP


$hote = 'localhost'; 
  $utilisateur = 'root'; 
  $password = ''; 
  $nombdd = 'incidents'; // gestion est le nom de ma base de données 
  $bdd = mysqli_connect($hote, $utilisateur, $password, $nombdd);
  if (!$bdd) { 
   echo 'Erreur de connexion (' . mysqli_connect_errno() . ') ' . mysqli_connect_error();
  }     
$nomusr= isset($_POST['nom_use'])?$_POST['nom_use']:NULL;
$preusr=isset($_POST['pre_use'])?$_POST['pre_use']:NULL;
$logusr=isset($_POST['log_in'])?$_POST['log_in']:NULL;
$pwdusr=isset($_POST['pwd_use'])?$_POST['pwd_use']:NULL;
$rolusr=isset($_POST['rol_use'])?$_POST['rol_use']:NULL;
$emausr=isset($_POST['ema_use'])?$_POST['ema_use']:NULL;

$req="INSERT INTO user(nom_use, pre_use, log_in, pwd_use, rol_use, ema_use, dep_use) VALUES('$nomusr','$preusr','$logusr','$pwdusr','$rolusr','$emausr',1)";
$req="insert into department values(null,'".$nomusr."')";
echo $req."</br>";
mysqli_query($bdd,$req) or die('Erreur'.mysqli_error($bdd));
if ((mysqli_query($bdd,$req)) === TRUE) {
    printf("Requete reussie\n");
} else{
echo "echec insertion";
}
mysqli_close($bdd);


RESULTAT DANS LE NAVIGATEUR
connexion OK
INSERT INTO user(nom_use, pre_use, log_in, pwd_use, rol_use, ema_use, dep_use) VALUES('namfain','guy','guy','password','MANAGER','namfain',1)
Requete reussie

Mais de données dans la base de données
[quote=Jean-Pierre-Bruneau]Peux-tu me donner le code de création des deux tables, merci

Voici le code de création de la table:


CREATE TABLE IF NOT EXISTS `user` (
  `id_use` int(10) NOT NULL AUTO_INCREMENT COMMENT 'Identifiant de l''utilisateur',
  `nom_use` varchar(50) COLLATE utf8_unicode_ci NOT NULL COMMENT 'nom de l''utilisateur',
  `pre_use` varchar(50) COLLATE utf8_unicode_ci NOT NULL COMMENT 'Prénom de l''utilisateur',
  `log_in` varchar(50) COLLATE utf8_unicode_ci NOT NULL COMMENT 'Login de l''utilisateur',
  `pwd_use` varchar(20) COLLATE utf8_unicode_ci NOT NULL COMMENT 'Mot de passe de l''utilisateur',
  `rol_use` varchar(30) COLLATE utf8_unicode_ci NOT NULL COMMENT 'Rôle de l''utilisateur',
  `ema_use` varchar(100) COLLATE utf8_unicode_ci NOT NULL COMMENT 'adresse email de l''utilisateur',
  `dep_use` int(4) NOT NULL COMMENT 'Département de l''utilisateur',
  PRIMARY KEY (`id_use`),
  KEY `dep_use` (`dep_use`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
Oui alors je l'ai fait en Mysql ça marche attention j'ai ignoré ta deuxième table !!

<?php
header('Content-type: text/html; charset=UTF-8');
try
     {
       $bdd = new PDO('mysql:host=127.0.0.1;dbname=jplyne', 'root', '');
       $bdd->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
       $bdd->exec("SET CHARACTER SET utf8");
      }
    catch(Exception $e)
     {
      die('Erreur : '.$e->getMessage());
     }



$nomusr= (isset($_POST['nom_use'])) ? $_POST['nom_use']:'';
$preusr=isset($_POST['pre_use'])?$_POST['pre_use']:'';
$logusr=isset($_POST['log_in'])?$_POST['log_in']:'';
$pwdusr=isset($_POST['pwd_use'])?$_POST['pwd_use']:'';
$rolusr=isset($_POST['rol_use'])?$_POST['rol_use']:'';
$emausr=isset($_POST['ema_use'])?$_POST['ema_use']:'';
if ($nomusr!="")   {
$zz=1;
$req = $bdd->prepare("INSERT IGNORE INTO `userx` (`nom_use`, `pre_use`, `log_in`, `pwd_use`, `rol_use`, `ema_use`, `dep_use`) VALUES
        (:le1,:le2,:le3,:le4,:le5,:le6,:le7)");
        $x=$req->execute(array( ':le1' => $nomusr,':le2' => $preusr,':le3' => $logusr,':le4' => $pwdusr,':le5' => $rolusr,':le6' => $emausr,':le7' => $zz));
        $ID=$bdd->lastInsertId();
        $req->closeCursor();


}
mysql_close($bdd);
?>
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!--[if IE]>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<![endif]--> 
<title>Colorisation code</title>
<meta name='keywords' content='Colorisation code' />
<meta name='description' content='Colorisation code' />
<meta name="robots" content="all">
<meta name="rating" content="general">
<meta name="revisit-after" content="30 days">
</head><body>
<div class='centre2blanc'>

<form class="form-horizontal well .well-md" name="add_user" method="post" action="test.php">
  
<div class="form-group">
    <label class="col-md-3 control-label" for="namuse">
      Last name
    </label>
    <div class="col-md-9">
      <input class="form-control" id="nameuse" name="nom_use" type="text" required="true" autofocus="true">
    </div>
  </div>
  
  
  <div class="form-group">
    <label class="col-md-3 control-label" for="preuse">
      First name
    </label>
    <div class="col-md-9">
	 <input class="form-control" id="preuse" name="pre_use" type="text" required="true">
    </div>
  </div>

  

  <div class="form-group">
    <label class="col-md-3 control-label" for="loguse">
      Login
    </label>
    <div class="col-md-9">
      <input class="form-control" id="loguse" name="log_in" type="text" required="true" onfocus="concatener()">
    </div>
  </div>
  
   <div class="form-group">
    <label class="col-md-3 control-label" for="passuse">
      Password
    </label>
    <div class="col-md-9">
      <input class="form-control" id="passuse" name="pwd_use" type="password" >
    </div>
  </div>
  
     
    <div class="form-group">
    <label class="col-md-3 control-label" for="roleuse">
      Role
    </label>
    <div class="col-md-9">
	 <select name="rol_use" id="roleuse" required="true">
      <option value="">- - -   Please choose an option   - - -</option>
      <option value="ADMINISTRATOR">ADMINISTRATOR</option>
      <option value="SUPER USER">SUPER USER</option>
      <option value="MANAGER">MANAGER</option>
      <option value="CONTROLLER">CONTROLLER</option>
      <option value="OPERATIONAL">OPERATIONAL</option>
	 </select>
    </div>
  </div> 
  
  <div class="form-group">
    <label class="col-md-3 control-label" for="email">
      Email
    </label>
    <div class="col-md-9">
	 <input class="form-control" id="email" name="ema_use" type="text" required="true" onfocus="concatener2()">
    </div>
  </div>
   
  
     
  <div class="row col-md-offset-5">
   
   <div class="col-md-3">  
    <button class="btn btn-primary" onClick="location.replace('.$page_home.');">Cancel</button>   
   </div>
   
   <div class="col-md-3 col-md-offset-1">  
    <input class="btn btn-primary" type="submit" value="Save">  
   </div>
   
  </div>  
</form>
</body></html>

ATTENTION J AI CHANGE LE NOM DE TABLE POUR TESTER
Modifié par Jean-Pierre-Bruneau (24 Jan 2020 - 18:27)