SOFARI HASSANE

SOFARI HASSANE

  • NA
  • 237
  • 21.7k

Problem when inserting data into DB

Jul 9 2019 4:10 AM
Hi everyone!
I do not know what happened to my code, I have trouble inserting data into the database and yet I have no errors
here is my code:
  1. <?php  
  2.      include_once('config.php');  
  3.        
  4.      if(isset($_POST['submit'])){  
  5.     $nom=isset($_POST['nom']);  
  6.     $prenom=isset($_POST['prenom']);  
  7.       
  8.     $phone=isset($_POST['phone']);  
  9.     $naissance=isset($_POST['naissance']);  
  10.     $lieu=isset($_POST['lieu']);  
  11.     $nationalite=isset($_POST['nationalite']);  
  12.     $passport=isset($_POST['passport']);  
  13.       
  14.     $ckckl[]=isset($_POST['chkl[]']) ;   
  15.       
  16.     $tmp=isset($_FILES['photo']['tmp_name']);  
  17.         $img=isset($_FILES['photo']['name']);  
  18.         $type=isset($_FILES['photo']['type']);  
  19.         if (is_uploaded_file($tmp)) {  
  20.             if (!strstr($type,'jpg') && !strstr($type,'png')){  
  21.                 echo "Ooops! veuillez choisir une image";  
  22.             }  
  23.             if (!move_uploaded_file($tmp,"./dist/img/$img")) {  
  24.                 echo "Désolé,destinantion non trouvée!";  
  25.             }  
  26.          
  27.       
  28.     
  29.     
  30.     $query="INSERT INTO pelerin (nom,prenom,genre,dateNaissance,lieuNaissance,nationalite,numPassport,photo) VALUES ('".$nom."','".$prenom."','".$genre."','".$phone."','".$naissance."','".$lieu."','".$nationalite."','".$passport."','".$img."')";    
  31.          mysqli_query($conn,$query);    
  32.     
  33.          echo "Record is inserted";    
  34.    
  35.  }  
  36.   }  
  37.  ?>  
  1. <form role="form" action="insert.php" method="post">  
  2.                   <div class="box-body">  
  3.                   <div class="form-group">  
  4.                       <label for="exampleInputName">Nom</label>  
  5.                       <input type="text" class="form-control" id="exampleInputName" placeholder="Entrer le nom" name="nom">  
  6.                     </div>  
  7.                     <div class="form-group">  
  8.                       <label for="exampleInputPrenom">Prénom</label>  
  9.                       <input type="text" class="form-control" id="exampleInputPrenom" placeholder="Entrer le prénom" name="prenom">  
  10.                     </div>  
  11.                     <div class="form-group">  
  12.                     <label for="exampleInputGenre">Genre</label>  
  13.                     <label class="checkbox-inline">  
  14.                    <input type="checkbox" value="" name="ckckl[]">M   
  15.                     </label>  
  16.                     <label class="checkbox-inline">  
  17.                     <input type="checkbox" value="" name="ckckl[]">F  
  18.                        </label>  
  19.                      </div>  
  20.                         <div class="form-group">  
  21.                       <label for="exampleInputPhone">Téléphone</label>  
  22.                       <input type="numbre" class="form-control" id="exampleInputPhone" placeholder="Entrer le téléphone" name="phone">  
  23.                     </div>  
  24.                         <div class="form-group">  
  25.                       <label for="exampleInputDate">Date de naissance</label>  
  26.                       <input type="Date" class="form-control" id="exampleInputDate" placeholder="Date de baissance" name="naissance">  
  27.                     </div>  
  28.                         <div class="form-group">  
  29.                       <label for="exampleInputLieu">Lieu de naissance</label>  
  30.                       <input type="text" class="form-control" id="exampleInputLieu" placeholder="Lieu de naissance" name="lieu">  
  31.                     </div>  
  32.                       
  33.                         <div class="form-group">  
  34.                       <label for="exampleInputNationalite">Nationalité</label>  
  35.                       <input type="text" class="form-control" id="exampleInputNationalite" placeholder="Entrer la nationalité" name="nationalite">  
  36.                     </div>  
  37.                         <div class="form-group">  
  38.                       <label for="exampleInputPassport">Numéro Passport</label>  
  39.                       <input type="text" class="form-control" id="exampleInputPassport" placeholder="Entrer le numéro du passport" name="passport">  
  40.                     </div>  
  41.                    
  42.                     <div class="form-group">  
  43.                       <label for="exampleInputFile">File input</label>  
  44.                       <input type="file" id="exampleInputFile" name="photo">  
  45.                         
  46.                     </div>  
  47.                      
  48.                   </div><!-- /.box-body -->  
  49.   
  50.                   <div class="box-footer">  
  51.                     <button type="submit" name="submit"class="btn btn-primary">Enregistrer</button>  
  52.                   </div>  
  53.                 </form>  
could someone help me to see more clearly, thank you in advance! 

Answers (1)