Back

Correction exercices les formulaires en php serie 01

Correction exercices formulaires en php serie 01

  1. Exercice 01

    • Énoncé
    • Solution
      • La page formulaireInscription.php (initialisation)
        • <!DOCTYPE html>
          <html lang="fr">
          
          <head>
              <meta charset="UTF-8">
              <meta http-equiv="X-UA-Compatible" content="IE=edge">
              <meta name="viewport" content="width=device-width, initial-scale=1.0">
              <link rel="stylesheet" href="style.css">
              <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
              <title>Exercice 1</title>
          </head>
          
          <body>
              <fieldset style="width: 70%;" class="scheduler-border">
                  <legend class="scheduler-border">Coordonées</legend>
                  <form method="POST">
                      <div class="row">
                          
                          <div class="form-group mx-auto col-lg-4">
                              <label for="surname">Prénom</label>
                              <input class="form-control" type="text" name="prenom" value=''>
                          </div>
                          <div class="form-group mx-auto col-lg-4">
                              <label for="name">Nom</label>
                              <input class="form-control" type="text" name="nom" value=''/>
                          </div>
                          <div class="form-group mx-auto col-lg-4">
                              <label for="dteNaissance">Date de naissance</label>
                              <input class="form-control" type="date" name="dteNaissance" value=''>
                          </div>
                          
                      </div>
                      
                      <div class="row">
                          <div class="form-group mx-auto col-lg-4">
                                                  <label>Genre</label></br>
                              <div class="form-check form-check-inline">
                                  <input class="form-check-input" type="radio" name="genre" id="inlineRadio1" value="Homme">
                                  <label class="form-check-label" for="inlineRadio1">Homme</label>
                              </div>
                              <div class="form-check form-check-inline">
                                  <input class="form-check-input" type="radio" name="genre" id="inlineRadio2" value="Femme">
                                  <label class="form-check-label" for="inlineRadio2">Femme</label>
                              </div>
                          </div>
                          <div class="form-group  mx-auto col-lg-4">
                               <label for="gov">Gouvernorat</label>                
                              <select id="gov" class="form-select" name="gouvernorat">
                                  <option selected value="">Choisir le gouvernorat</option>
                                  <option value="Ariana">Ariana</option>
                                  <option value="Béja">Béja</option>
                                  <option value="Ben Arous">Ben Arous</option>
                                  <option value="Bizerte" >Bizerte</option>
                                  <option value="Gabès">Gabès</option>
                                  <option value="Gafsa">Gafsa</option>
                                  <option value="Jendouba">Jendouba</option>
                                  <option value="Kairouan">Kairouan</option>
                                  <option value="Kasserine">Kasserine</option>
                                  <option value="Kebili">Kebili</option>
                                  <option value="Le Kef">Le Kef</option>
                                  <option value="Mahdia">Mahdia</option>
                                  <option value="Mannouba">Mannouba</option>
                                  <option value="Médenine">Médenine</option>
                                  <option value="Monastir">Monastir</option>
                                  <option value="Nabeul">Nabeul</option>
                                  <option value="Sfax">Sfax</option>
                                  <option value="Sidi Bouzid">Sidi Bouzid</option>
                                  <option value="Siliana">Siliana</option>
                                  <option value="Sousse">Sousse</option>
                                  <option value="Tataouine">Tataouine</option>
                                  <option value="Tozeur">Tozeur</option>
                                  <option value="Tunis">Tunis</option>
                                  <option value="Zaghouan">Zaghouan</option>
                              </select>
                          </div>
                          <div class="form-group mx-auto  col-lg-4">
                              <label for="postal">Code Postal</label>
                              <input class="form-control" type="number" name="cdepostal" value='' >
                          </div>
                      </div>    
                          
                          <div class="row">
                              <div class="form-group mx-auto col-lg-12">
                                  <label for="address">Adresse</label>
                                  <input class="form-control" type="text" name="adresse" value=''>
                              </div>
                          </div>
                      <div class="row">
                          <div class="form-group mx-auto col-lg-4">
                              <label for="username">Nom d'utilisateur</label>
                              <input class="form-control" type="text" name="nomUtilisateur" value=''>
                          </div>
                          <div class="form-group mx-auto col-lg-4">
                              <label for="psw">Mot de passe</label>
                              <input class="form-control" type="password" name="password" value=''>
                          </div>
                          <div class="form-group mx-auto col-lg-4">
                              <label for="psw">Réécrire mot de passe</label>
                              <input class="form-control" type="password" name="repassword" value=''>
                          </div>
                      </div>
                      <div class="row">           
                          <div class="form-group mx-auto col-lg-4">
                          <label>Domaines</label>  
                              <select class="form-select" name="domaine">
                                  <option selected value="">Choisir un domaine</option>
                                  <option value="Informatiques">Informatiques</option>
                                  <option value="Finance">Finance</option>
                                  <option value="Marketing">Marketing</option>
                                  <option value="Logistique">Logistique</option>
                                  <option value="Comptabilité">Comptabilité</option>
                              </select>
                          </div>
                          <div class="form-group mx-auto col-lg-8">
                                  <label for="psw">Autres domaines</label>
                                  <input class="form-control" type="text" name="autreDomaine"value=''>
                          </div>
                      </div> 
                      <div class="row pt-2"> 
                              <div class="d-grid gap-2 col-lg-6">
                                  <input class="btn btn-danger" type="reset" value="Effacer"/>
                              </div>
                              <div class="d-grid gap-2 col-lg-6">
                                  <input class="btn btn-primary" type="submit" name="valider" value="Validez votre inscription"/>
                              </div>
                      </div>
          </form>
          </fieldset>
                          <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM" crossorigin="anonymous"></script>
          </body>
          
          </html>
      • La page formulaireInscription.php
        • <?php
          
          function calculerAge($date){
              $today = date("Y-m-d");
              $newDate = date('Y-m-d', strtotime($date. ' + 12 years'));
              //echo  "Aujourdhui ".$today;
              //echo  "eedde ".$newDate;
              if( $newDate<=$today){
                  return true;
              }else{
                   return false;
              }   
          }
          
          
          
          if(isset($_POST['valider'])){
              $nom=$_POST["nom"];
             $prenom=$_POST["prenom"];
              $dteNaissance=$_POST["dteNaissance"];
          
              if(!empty($_POST["genre"])){
                  $genre=$_POST["genre"];
              }
             $gouvernorat=$_POST["gouvernorat"];
          
             $cdepostal=$_POST["cdepostal"];
             $adresse=$_POST["adresse"];
          
             $nomUtilisateur=$_POST["nomUtilisateur"];
          
             
             $password=$_POST["password"];
             $repassword=$_POST["repassword"];
             
             $domaine=$_POST["domaine"];
             $autreDomaine=$_POST["autreDomaine"];
            
             $valider=$_POST["valider"];
             if(isset($valider)){
                if(empty($nom)){
                   $message='<div class="erreur">Nom laissé vide.</div>';}
                elseif(empty($prenom)){
                   $message='<div class="erreur">Prénom laissé vide.</div>';}
              elseif(empty($dteNaissance)){
                      $message='<div class="erreur">Date de naissance laissée vide.</div>';}
               elseif(calculerAge($dteNaissance)==false){       
                      $message='<div class="erreur">L\'âge minimal requis pour gérer votre compte est de 12 ans.</div>';}
              elseif(empty($genre)){
                          $message='<div class="erreur">Genre n\'est pas choisi.</div>';}  
              elseif(empty($gouvernorat)){
                   $message='<div class="erreur">gouvernorat laissé vide.</div>';}
                elseif(empty($cdepostal)){
                   $message='<div class="erreur">Le champ Code postal laissé vide.</div>';}
                elseif(empty($adresse)){
                   $message='<div class="erreur">Le champ Adresse laissé vide.</div>';}
                elseif(empty($nomUtilisateur)){
                   $message='<div class="erreur">Le champ Nom d\'utilisateur laissé vide.</div>';}      
                elseif(empty($password)){
                   $message='<div class="erreur">Le champ Mot de passe laissé vide.</div>';}
                elseif($password!=$repassword){
                   $message='<div class="erreur">Les mots de passe ne sont pas identiques.</div>';}
                elseif(empty($domaine)){
                   $message='<div class="erreur">Le champ domaine laissé vide.</div>';}  
              else{
          
                  
                  //header("Location: affichage.php");
                  $url = "affichage.php?nom=$nom&prenom=$prenom&dteNaissance=$dteNaissance";
                   $url = $url."&genre=$genre&gouvernorat=$gouvernorat&cdepostal=$cdepostal&adresse=$adresse";
                  $url = $url."&nomUtilisateur=$nomUtilisateur&password=$password&domaine=$domaine&autreDomaine=$autreDomaine";
          
                  header("Location: ".$url);
                }
             }
          }
          ?> 
          <!DOCTYPE html>
          <html lang="fr">
          
          <head>
              <meta charset="UTF-8">
              <meta http-equiv="X-UA-Compatible" content="IE=edge">
              <meta name="viewport" content="width=device-width, initial-scale=1.0">
              <link rel="stylesheet" href="style.css">
              <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
              <title>Exercice 1</title>
          </head>
          
          <body>
              <fieldset style="width: 70%;" class="scheduler-border">
                  <legend class="scheduler-border">Coordonées</legend>
                  <?php 
                  if(isset($_POST['valider'])){
                      echo $message; 
                  }
              ?>  
                  <form method="POST">
                      <div class="row">
                          
                          <div class="form-group mx-auto col-lg-4">
                              <label for="surname">Prénom</label>
                              <input class="form-control" type="text" name="prenom" value='<?php if(isset($_POST['valider']) && !empty($_POST['prenom'])){echo $_POST['prenom'];} ?>'>
                          </div>
                          <div class="form-group mx-auto col-lg-4">
                              <label for="name">Nom</label>
                              <input class="form-control" type="text" name="nom" value='<?php if(isset($_POST['valider']) && !empty($_POST['nom'])){echo $_POST['nom'];} ?>'/>
                          </div>
                          <div class="form-group mx-auto col-lg-4">
                              <label for="dteNaissance">Date de naissance</label>
                              <input class="form-control" type="date" name="dteNaissance" value='<?php if(isset($_POST['valider']) && !empty($_POST['dteNaissance'])){echo $_POST['dteNaissance'];} ?>'>
                          </div>
                          
                      </div>
                      
                      <div class="row">
                          <div class="form-group mx-auto col-lg-4">
                                                  <label>Genre</label></br>
                              <div class="form-check form-check-inline">
                                  <input class="form-check-input" type="radio" name="genre" id="inlineRadio1" value="Homme" <?php if(isset($_POST['valider']) && $genre=='Homme'){echo 'checked';} ?>>
                                  <label class="form-check-label" for="inlineRadio1">Homme</label>
                              </div>
                              <div class="form-check form-check-inline">
                                  <input class="form-check-input" type="radio" name="genre" id="inlineRadio2" value="Femme" <?php if(isset($_POST['valider']) && $genre=='Femme'){echo 'checked';} ?>>
                                  <label class="form-check-label" for="inlineRadio2">Femme</label>
                              </div>
                          </div>
                          <div class="form-group  mx-auto col-lg-4">
                               <label for="gov">Gouvernorat</label>                
                              <select id="gov" class="form-select" name="gouvernorat">
                                  <option selected value="">Choisir le gouvernorat</option>
                                  <option value="Ariana" <?php if(isset($_POST['valider']) && $gouvernorat=='Ariana'){echo 'selected';} ?>>Ariana</option>
                                  <option value="Béja"<?php if(isset($_POST['valider']) && $gouvernorat=='Béja'){echo 'selected';} ?>>Béja</option>
                                  <option value="Ben Arous" <?php if(isset($_POST['valider']) && $gouvernorat=='Ben Arous'){echo 'selected';} ?>>Ben Arous</option>
                                  <option value="Bizerte" <?php if(isset($_POST['valider']) && $gouvernorat=='Bizerte'){echo 'selected';} ?>>Bizerte</option>
                                  <option value="Gabès" <?php if(isset($_POST['valider']) && $gouvernorat=='Gabès'){echo 'selected';} ?>>Gabès</option>
                                  <option value="Gafsa" <?php if(isset($_POST['valider']) && $gouvernorat=='Gafsa'){echo 'selected';} ?>>Gafsa</option>
                                  <option value="Jendouba" <?php if(isset($_POST['valider']) && $gouvernorat=='Jendouba'){echo 'selected';} ?>>Jendouba</option>
                                  <option value="Kairouan" <?php if(isset($_POST['valider']) && $gouvernorat=='Kairouan'){echo 'selected';} ?>>Kairouan</option>
                                  <option value="Kasserine" <?php if(isset($_POST['valider']) && $gouvernorat=='Kasserine'){echo 'selected';} ?>>Kasserine</option>
                                  <option value="Kebili" <?php if(isset($_POST['valider']) && $gouvernorat=='Kebili'){echo 'selected';} ?>>Kebili</option>
                                  <option value="Le Kef" <?php if(isset($_POST['valider']) && $gouvernorat=='Le Kef'){echo 'selected';} ?>>Le Kef</option>
                                  <option value="Mahdia" <?php if(isset($_POST['valider']) && $gouvernorat=='Mahdia'){echo 'selected';} ?>>Mahdia</option>
                                  <option value="Mannouba" <?php if(isset($_POST['valider']) && $gouvernorat=='Mannouba'){echo 'selected';} ?>>Mannouba</option>
                                  <option value="Médenine" <?php if(isset($_POST['valider']) && $gouvernorat=='Médenine'){echo 'selected';} ?>>Médenine</option>
                                  <option value="Monastir" <?php if(isset($_POST['valider']) && $gouvernorat=='Monastir'){echo 'selected';} ?>>Monastir</option>
                                  <option value="Nabeul" <?php if(isset($_POST['valider']) && $gouvernorat=='Nabeul'){echo 'selected';} ?>>Nabeul</option>
                                  <option value="Sfax" <?php if(isset($_POST['valider']) && $gouvernorat=='Sfax'){echo 'selected';} ?>>Sfax</option>
                                  <option value="Sidi Bouzid" <?php if(isset($_POST['valider']) && $gouvernorat=='Sidi Bouzid'){echo 'selected';} ?>>Sidi Bouzid</option>
                                  <option value="Siliana" <?php if(isset($_POST['valider']) && $gouvernorat=='Siliana'){echo 'selected';} ?>>Siliana</option>
                                  <option value="Sousse" <?php if(isset($_POST['valider']) && $gouvernorat=='Sousse'){echo 'selected';} ?>>Sousse</option>
                                  <option value="Tataouine" <?php if(isset($_POST['valider']) && $gouvernorat=='Tataouine'){echo 'selected';} ?>>Tataouine</option>
                                  <option value="Tozeur" <?php if(isset($_POST['valider']) && $gouvernorat=='Tozeur'){echo 'selected';} ?>>Tozeur</option>
                                  <option value="Tunis" <?php if(isset($_POST['valider']) && $gouvernorat=='Tunis'){echo 'selected';} ?>>Tunis</option>
                                  <option value="Zaghouan" <?php if(isset($_POST['valider']) && $gouvernorat=='Zaghouan'){echo 'selected';} ?>>Zaghouan</option>
                              </select>
                          </div>
                          <div class="form-group mx-auto  col-lg-4">
                              <label for="postal">Code Postal</label>
                              <input class="form-control" type="number" name="cdepostal" value='<?php if(isset($_POST['valider']) && !empty($_POST['cdepostal'])){echo $_POST['cdepostal'];} ?>' >
                          </div>
                      </div>    
                          
                          <div class="row">
                              <div class="form-group mx-auto col-lg-12">
                                  <label for="address">Adresse</label>
                                  <input class="form-control" type="text" name="adresse" value='<?php if(isset($_POST['valider']) && !empty($_POST['adresse'])){echo $_POST['adresse'];} ?>'>
                              </div>
                          </div>
                      <div class="row">
                          <div class="form-group mx-auto col-lg-4">
                              <label for="username">Nom d'utilisateur</label>
                              <input class="form-control" type="text" name="nomUtilisateur" value='<?php if(isset($_POST['valider']) && !empty($_POST['nomUtilisateur'])){echo $_POST['nomUtilisateur'];} ?>'>
                          </div>
                          <div class="form-group mx-auto col-lg-4">
                              <label for="psw">Mot de passe</label>
                              <input class="form-control" type="password" name="password" value='<?php if(isset($_POST['valider']) && !empty($_POST['password'])){echo $_POST['password'];} ?>'>
                          </div>
                          <div class="form-group mx-auto col-lg-4">
                              <label for="psw">Réécrire mot de passe</label>
                              <input class="form-control" type="password" name="repassword" value='<?php if(isset($_POST['valider']) && !empty($_POST['repassword'])){echo $_POST['repassword'];} ?>'>
                          </div>
                      </div>
                      <div class="row">           
                          <div class="form-group mx-auto col-lg-4">
                          <label>Domaines</label>  
                              <select class="form-select" name="domaine">
                                  <option selected value="">Choisir un domaine</option>
                                  <option value="Informatiques" <?php if(isset($_POST['valider']) && $domaine=='Informatiques'){echo 'selected';} ?>>Informatiques</option>
                                  <option value="Finance"<?php if(isset($_POST['valider']) && $domaine=='Finance'){echo 'selected';} ?>>Finance</option>
                                  <option value="Marketing" <?php if(isset($_POST['valider']) && $domaine=='Marketing'){echo 'selected';} ?>>Marketing</option>
                                  <option value="Logistique" <?php if(isset($_POST['valider']) && $domaine=='Logistique'){echo 'selected';} ?>>Logistique</option>
                                  <option value="Comptabilité" <?php if(isset($_POST['valider']) && $domaine=='Comptabilité'){echo 'selected';} ?>>Comptabilité</option>
                              </select>
                          </div>
                          <div class="form-group mx-auto col-lg-8">
                                  <label for="psw">Autres domaines</label>
                                  <input class="form-control" type="text" name="autreDomaine"value='<?php if(isset($_POST['valider']) && !empty($_POST['autreDomaine'])){echo $_POST['autreDomaine'];} ?>'>
                          </div>
                      </div> 
                      <div class="row pt-2"> 
                              <div class="d-grid gap-2 col-lg-6">
                                  <input class="btn btn-danger" type="reset" value="Effacez"/>
                              </div>
                              <div class="d-grid gap-2 col-lg-6">
                                  <input class="btn btn-primary" type="submit" name="valider" value="Validez votre inscription"/>
                              </div>
                      </div>
          </form>
          </fieldset>
                          <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM" crossorigin="anonymous"></script>
          </body>
          
          </html>
      • La page affichage.php
        • <!DOCTYPE html>
          <html lang="fr">
          
          <head>
              <meta charset="UTF-8">
              <meta http-equiv="X-UA-Compatible" content="IE=edge">
              <meta name="viewport" content="width=device-width, initial-scale=1.0">
              <link rel="stylesheet" href="style.css">
              <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
              <title>Exercice 1</title>
          </head>
          
          <body>
              <fieldset style="width: 70%;" class="scheduler-border">
                  <legend class="scheduler-border">Coordonées</legend>
                  <?php 
                  echo'<div class="rappel"><b>Bonjour !:</b><br />';
                  echo "<span class='normal'>Vous êtes  : </span>".ucfirst(strtolower($_GET['nom'])) . " ".strtoupper($_GET['prenom'])." ".($_GET['genre'])."<br>";
                  echo "<span class='normal'>Vous êtes nés le : </span>".$_GET['dteNaissance'] ." <span class='normal'>à </span>". $_GET['gouvernorat']."<br>";
                  echo "<span class='normal'>Vous habitez à : </span>".$_GET['adresse'] ." <span class='normal'>code postal </span>". $_GET['cdepostal']."<br>";
                  echo "<span class='normal'>Votre nom d'utilisateur est :</span>".$_GET['nomUtilisateur']."<span class='normal'> votre mot de passe est :</span>".$_GET['password']."<br>";
                  echo "<span class='normal'>Vous avez choisis le domaine :</span>".$_GET['domaine']."<br>";
          
                  
                  echo'</div>';
              ?>  
                                     
          </fieldset>
                          <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM" crossorigin="anonymous"></script>
          </body>
          
          </html>

          –>

      • La page style.css
        • *,
          *::before,
          *::after {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
          }
          
          body {
            height: 100vh;
            width: 100%;
            display: flex;
            align-items: center;
            justify-content: center;
          }
          
          fieldset.scheduler-border {
            border-radius: 5px;
          Border:2px solid #999900;
          padding:0px 20px 10px;
            margin: 0 0 1.5em 0 !important;
            box-shadow: 0px 0px 0px 0px #000;
            margin-top: 30px !important;
          }
          
          legend.scheduler-border {
            font-size: 1.5em !important;
            font-weight: bold !important;
            text-align: left !important;
            width: auto;
            padding: 0 10px;
            border-bottom: none;
            margin-top: -25px;
            background-color: white;
            color: rgb(15, 49, 241);
          }
          .erreur{
            font:14pt arial;
            color:#DD0000;
            background-color:#EEEEEE;
            padding:10px;
            border-radius:6px;
            margin-bottom:10px;
          }
          .rappel{
            font:16pt arial;
            font-weight: bolder;
            line-height: 2;
            color:#a2c2a2;
            background-color:#EEEEEE;
            padding:10px;
            border-radius:10px;
            margin-bottom:10px;
          }
          .normal{
            font:14pt arial;
            color:#888888;
          }



  • Exercice 02

    1. Énoncé
    2. Solution
      • La page Inscription.php
        • <?php
          /*By that it means, instead of using
          
          $_SERVER['HTTP_CLIENT_IP'];
          $_SERVER['HTTP_X_FORWARDED_FOR'];
          You then use these arrays on localhost:
          
          getenv('REMOTE_ADDR');
          getenv('HTTP_X_FORWARDED_FOR');*/
          
          if(isset($_POST['valider'])){
              $nom=$_POST["nom"];
             $prenom=$_POST["prenom"];
              $dteNaissance=$_POST["dteNaissance"];
          $genre="";
              if(!empty($_POST["genre"])){
                  $genre=$_POST["genre"];
              }
             $gouvernorat=$_POST["gouvernorat"];
          $email=$_POST["email"];
          $navigateur=$_SERVER['HTTP_USER_AGENT'];
          $adresseIp=getenv('REMOTE_ADDR');
          $machine=gethostname();
            
          
             $valider=$_POST["valider"];
             if(isset($valider)){
                if(empty($nom)){
                   $message='<div class="erreur">Nom laissé vide.</div>';}
                elseif(empty($prenom)){
                   $message='<div class="erreur">Prénom laissé vide.</div>';}
              elseif(empty($dteNaissance)){
                      $message='<div class="erreur">Date de naissance laissée vide.</div>';}
               
              elseif(empty($genre)){
                          $message='<div class="erreur">Genre n\'est pas choisi.</div>';}  
              elseif(empty($gouvernorat)){
                   $message='<div class="erreur">Le gouvernorat de naissance n\'est pas choisi.</div>';}
                elseif(empty($email)){
                   $message='<div class="erreur">Le champ Email est vide.</div>';}
              else{
                  $url = "verifier.php?nom=$nom&prenom=$prenom&dteNaissance=$dteNaissance";
                   $url = $url."&genre=$genre&gouvernorat=$gouvernorat&email=$email";
                  $url = $url."&navigateur=$navigateur&adresseIp=$adresseIp&machine=$machine";
          
                  header("Location: ".$url);
                }
             }
          }
          ?> 
          <!DOCTYPE html>
          <html lang="fr">
          
          <head>
              <meta charset="UTF-8">
              <meta http-equiv="X-UA-Compatible" content="IE=edge">
              <meta name="viewport" content="width=device-width, initial-scale=1.0">
              <link rel="stylesheet" href="style.css">
              <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
              <title>Exercice 1</title>
          </head>
          
          <body>
              <fieldset style="width: 70%;" class="scheduler-border">
                  <legend class="scheduler-border">Coordonées</legend>
                  <?php 
                  if(isset($_POST['valider'])){
                      echo $message; 
                  }
              ?>  
                  <form method="POST">
                      <div class="row">
                          
                          <div class="form-group mx-auto col-lg-4">
                              <label for="surname">Prénom</label>
                              <input class="form-control" type="text" name="prenom" value='<?php if(isset($_POST['valider']) && !empty($_POST['prenom'])){echo $_POST['prenom'];} ?>'>
                          </div>
                          <div class="form-group mx-auto col-lg-4">
                              <label for="name">Nom</label>
                              <input class="form-control" type="text" name="nom" value='<?php if(isset($_POST['valider']) && !empty($_POST['nom'])){echo $_POST['nom'];} ?>'/>
                          </div>
                          <div class="form-group mx-auto col-lg-4">
                              <label for="dteNaissance">Date de naissance</label>
                              <input class="form-control" type="date" name="dteNaissance" value='<?php if(isset($_POST['valider']) && !empty($_POST['dteNaissance'])){echo $_POST['dteNaissance'];} ?>'>
                          </div>
                          
                      </div>
                      
                      <div class="row">
                          <div class="form-group mx-auto col-lg-4">
                                                  <label>Genre</label></br>
                              <div class="form-check form-check-inline">
                                  <input class="form-check-input" type="radio" name="genre" id="inlineRadio1" value="Homme" <?php if(isset($_POST['valider']) && $genre=='Homme'){echo 'checked';} ?>>
                                  <label class="form-check-label" for="inlineRadio1">Homme</label>
                              </div>
                              <div class="form-check form-check-inline">
                                  <input class="form-check-input" type="radio" name="genre" id="inlineRadio2" value="Femme" <?php if(isset($_POST['valider']) && $genre=='Femme'){echo 'checked';} ?>>
                                  <label class="form-check-label" for="inlineRadio2">Femme</label>
                              </div>
                          </div>
                          <div class="form-group  mx-auto col-lg-4">
                               <label for="gov">Gouvernorat</label>                
                              <select id="gov" class="form-select" name="gouvernorat">
                                  <option selected value="">Choisir le gouvernorat</option>
                                  <option value="Ariana" <?php if(isset($_POST['valider']) && $gouvernorat=='Ariana'){echo 'selected';} ?>>Ariana</option>
                                  <option value="Béja"<?php if(isset($_POST['valider']) && $gouvernorat=='Béja'){echo 'selected';} ?>>Béja</option>
                                  <option value="Ben Arous" <?php if(isset($_POST['valider']) && $gouvernorat=='Ben Arous'){echo 'selected';} ?>>Ben Arous</option>
                                  <option value="Bizerte" <?php if(isset($_POST['valider']) && $gouvernorat=='Bizerte'){echo 'selected';} ?>>Bizerte</option>
                                  <option value="Gabès" <?php if(isset($_POST['valider']) && $gouvernorat=='Gabès'){echo 'selected';} ?>>Gabès</option>
                                  <option value="Gafsa" <?php if(isset($_POST['valider']) && $gouvernorat=='Gafsa'){echo 'selected';} ?>>Gafsa</option>
                                  <option value="Jendouba" <?php if(isset($_POST['valider']) && $gouvernorat=='Jendouba'){echo 'selected';} ?>>Jendouba</option>
                                  <option value="Kairouan" <?php if(isset($_POST['valider']) && $gouvernorat=='Kairouan'){echo 'selected';} ?>>Kairouan</option>
                                  <option value="Kasserine" <?php if(isset($_POST['valider']) && $gouvernorat=='Kasserine'){echo 'selected';} ?>>Kasserine</option>
                                  <option value="Kebili" <?php if(isset($_POST['valider']) && $gouvernorat=='Kebili'){echo 'selected';} ?>>Kebili</option>
                                  <option value="Le Kef" <?php if(isset($_POST['valider']) && $gouvernorat=='Le Kef'){echo 'selected';} ?>>Le Kef</option>
                                  <option value="Mahdia" <?php if(isset($_POST['valider']) && $gouvernorat=='Mahdia'){echo 'selected';} ?>>Mahdia</option>
                                  <option value="Mannouba" <?php if(isset($_POST['valider']) && $gouvernorat=='Mannouba'){echo 'selected';} ?>>Mannouba</option>
                                  <option value="Médenine" <?php if(isset($_POST['valider']) && $gouvernorat=='Médenine'){echo 'selected';} ?>>Médenine</option>
                                  <option value="Monastir" <?php if(isset($_POST['valider']) && $gouvernorat=='Monastir'){echo 'selected';} ?>>Monastir</option>
                                  <option value="Nabeul" <?php if(isset($_POST['valider']) && $gouvernorat=='Nabeul'){echo 'selected';} ?>>Nabeul</option>
                                  <option value="Sfax" <?php if(isset($_POST['valider']) && $gouvernorat=='Sfax'){echo 'selected';} ?>>Sfax</option>
                                  <option value="Sidi Bouzid" <?php if(isset($_POST['valider']) && $gouvernorat=='Sidi Bouzid'){echo 'selected';} ?>>Sidi Bouzid</option>
                                  <option value="Siliana" <?php if(isset($_POST['valider']) && $gouvernorat=='Siliana'){echo 'selected';} ?>>Siliana</option>
                                  <option value="Sousse" <?php if(isset($_POST['valider']) && $gouvernorat=='Sousse'){echo 'selected';} ?>>Sousse</option>
                                  <option value="Tataouine" <?php if(isset($_POST['valider']) && $gouvernorat=='Tataouine'){echo 'selected';} ?>>Tataouine</option>
                                  <option value="Tozeur" <?php if(isset($_POST['valider']) && $gouvernorat=='Tozeur'){echo 'selected';} ?>>Tozeur</option>
                                  <option value="Tunis" <?php if(isset($_POST['valider']) && $gouvernorat=='Tunis'){echo 'selected';} ?>>Tunis</option>
                                  <option value="Zaghouan" <?php if(isset($_POST['valider']) && $gouvernorat=='Zaghouan'){echo 'selected';} ?>>Zaghouan</option>
                              </select>
                          </div>
                          <div class="form-group mx-auto  col-lg-4">
                              <label for="postal">Email</label>
                              <input class="form-control" type="mail" name="email" value='<?php if(isset($_POST['valider']) && !empty($_POST['email'])){echo $_POST['email'];} ?>' >
                          </div>
                      </div>    
                          
                      <hr class="border border-primary border-3 opacity-75">
          
                      <input type="hidden" name="navigateur" value='<?php if(isset($_POST['valider'])){echo $navigateur;} ?>' />
                      <input type="hidden" name="adresseIp" value='<?php if(isset($_POST['valider'])){echo $adresseIp;} ?>' />
                      <input type="hidden" name="machine" value='<?php if(isset($_POST['valider'])){echo $machine;} ?>' />
          
                      <div class="row pt-2"> 
                              <div class="d-grid gap-2 col-lg-6">
                                  <input class="btn btn-danger" type="reset" value="Effacer"/>
                              </div>
                              <div class="d-grid gap-2 col-lg-6">
                                  <input class="btn btn-primary" type="submit" name="valider" value="Validez votre inscription"/>
                              </div>
                      </div>
          </form>
          </fieldset>
                          <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM" crossorigin="anonymous"></script>
          </body>
          
          </html>
      • La page verifier.php
        • <!DOCTYPE html>
          <html lang="fr">
          
          <head>
              <meta charset="UTF-8">
              <meta http-equiv="X-UA-Compatible" content="IE=edge">
              <meta name="viewport" content="width=device-width, initial-scale=1.0">
              <link rel="stylesheet" href="style.css">
              <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
              <title>Exercice 1</title>
          </head>
          
          <body>
              <fieldset style="width: 70%;" class="scheduler-border">
                  <legend class="scheduler-border">Coordonées</legend>
                  <?php 
                  echo'<div class="rappel"><b>Bonjour !:</b><br />';
                  echo "<span class='normal'>Vous êtes  : </span>".ucfirst(strtolower($_GET['nom'])) . " ".strtoupper($_GET['prenom'])." ".($_GET['genre'])."<br>";
                  echo "<span class='normal'>Vous êtes nés le : </span>".$_GET['dteNaissance'] ." <span class='normal'>à </span>". $_GET['gouvernorat']."<br>";
                  echo "<span class='normal'>Votre navigateur est : </span>".$_GET['navigateur']."<br>";
                  echo "<span class='normal'>Votre adresse IP est :</span>".$_GET['adresseIp']."<br>";
                  echo "<span class='normal'>Votre machine est :</span>".$_GET['machine']."<br>";
          
                  
                  echo'</div>';
              ?>  
                                     
          </fieldset>
                          <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM" crossorigin="anonymous"></script>
          </body>
          
          </html>

          –>

      • La page style.css
        • *,
          *::before,
          *::after {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
          }
          
          body {
            height: 100vh;
            width: 100%;
            display: flex;
            align-items: center;
            justify-content: center;
          }
          
          fieldset.scheduler-border {
            border-radius: 5px;
          Border:2px solid #999900;
          padding:0px 20px 10px;
            margin: 0 0 1.5em 0 !important;
            box-shadow: 0px 0px 0px 0px #000;
            margin-top: 30px !important;
          }
          
          legend.scheduler-border {
            font-size: 1.5em !important;
            font-weight: bold !important;
            text-align: left !important;
            width: auto;
            padding: 0 10px;
            border-bottom: none;
            margin-top: -25px;
            background-color: white;
            color: rgb(15, 49, 241);
          }
          .erreur{
            font:14pt arial;
            color:#DD0000;
            background-color:#EEEEEE;
            padding:10px;
            border-radius:6px;
            margin-bottom:10px;
          }
          .rappel{
            font:16pt arial;
            font-weight: bolder;
            line-height: 2;
            color:#a2c2a2;
            background-color:#EEEEEE;
            padding:10px;
            border-radius:10px;
            margin-bottom:10px;
          }
          .normal{
            font:14pt arial;
            color:#888888;
          }
    3. Exercice 06

      1. Énoncé
      2. Solution
        • <!doctype html>
          <html lang="fr">
            <head>
              <!-- Required meta tags -->
              <meta charset="utf-8">
              <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
          
              <!-- Bootstrap CSS -->
              <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
          
              <title>Afficher le tableau multiplication</title>
              <style>
          fieldset {
          			border: 2px solid #dcdcdc;
          			border-radius: 10px;
          			padding: 10px 20px;
          			text-align: leftt;
          		}
              legend {width:15%}    
          </style>
            </head>
            <body>
          <div class="container">
          </br>
          <fieldset class="border p-4">
              <legend class="w-auto">Dimensions</legend>
          <form class="form-inline" method="post">
              <label for="nbrligne" class="mr-sm-2">Saisir la longueur des lignes</label>
              <input type="number"  class="form-control mb-2 mr-sm-2" name="txt_nbrligne" value="<?php if(isset($_POST['txt_nbrligne'])) echo $_POST['txt_nbrligne'];?>">
          
              <label for="nbrcolonne" class="mr-sm-2">Saisir la longueur des colonnes</label>
              <input type="number"  class="form-control mb-2 mr-sm-2" name="txt_nbrcolonne" value="<?php if(isset($_POST['txt_nbrcolonne'])) echo $_POST['txt_nbrcolonne'];?>">
          
            <button type="submit" class="btn btn-primary mb-2" name="submit">Générer le tableau</button>
          </form>
          </fieldset>
          
          <?php
          if(isset($_POST["submit"]) && isset($_POST["txt_nbrligne"]) && isset($_POST["txt_nbrcolonne"])){
          $nbrligne=$_POST["txt_nbrligne"];
          $nbrcolonne=$_POST["txt_nbrcolonne"];
          /*
          function cl($i,$j)
           {
          $r="background-color:chocolate";
          $c="background-color:coral";
          
          $k="background-color:khaki";
             if($i==0 ){
                return $r;
                }elseif($i%2==1){
          	    
               return $c;
                   }else{
          	   return $k;
          	  }
           }
           */
          echo"<caption> Tableau  de multiplication </caption>";
          echo"<table  class='table table-bordered'>";
           for($i=1;$i<=$nbrligne;$i++)
           {       
             echo"<tr align='center'>";
              for($j=1;$j<=$nbrcolonne;$j++)
              {
                if($i==1){echo "<th scope='col' bgcolor='#E8F0FE'>".$i*$j."</th>";}
          
                elseif($j==1){echo "<th scope='col' bgcolor='#E8F0FE'>".$i*$j."</th>";}
                else{echo "<td>".$i*$j."</td>";}	  
          	  } 
             	
               echo"</tr>";
           }
          echo"</table>"; 
          }
          $nbrligne="";
          $nbrcolonne="";
          ?>
          </div>
          <!-- Optional JavaScript -->
              <!-- jQuery first, then Popper.js, then Bootstrap JS -->
              <script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
              <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
              <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
            </body>
          </html>
          
    4. Exercice 07

      1. Énoncé
      2. Solution
        1. Fichier calcul_pret.html
          • <!doctype html>
            <html lang="fr">
              <head>
                <!-- Required meta tags -->
                <meta charset="utf-8">
                <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
            
                <!-- Bootstrap CSS -->
                <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
            
                <title>Afficher le tableau multiplication</title>
                <style>
            fieldset {
            			border: 2px solid #dcdcdc;
            			border-radius: 10px;
            			padding: 10px 20px;
            			text-align: leftt;
            		}
                legend {
            		width:36%;
            		}    
            </style>
              </head>
              <body>
            <div class="container">
              <h3>Prêts </h3>
              <form method="post" action="calcul_pret.php">
              <fieldset>
              <legend>Les caractéristiques de votre prêt</legend>
              <table>
              <tr>
              <td>Montant</td>
              <td><input type="text" name="capital" /></td>
              </tr>
              <tr>
              <td>Taux</td>
              <td><input type="text" name="taux" /></td>
            </tr>
            <tr>
            <td>Durée en année</td>
            <td><input type="text" name="duree" /></td>
            </tr>
            <tr>
            <td>Assurance</td>
            <td>OUI : <input type="radio" name="assur" checked="checked" value="1" />&nbsp; NON<input type="radio" name="assur" value="0" /></td>
            </tr>
            <tr>
             
            <td> <button type="reset" class="btn btn-primary mb-2" name="effacer">Effacer</button></td>
            <td><button type="submit" class="btn btn-primary mb-2" name="envoyer">Envoyer</button></td>
            </tr>
            </table>
            </fieldset>
            </form>
            </div>
            <!-- Optional JavaScript -->
                <!-- jQuery first, then Popper.js, then Bootstrap JS -->
                <script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
                <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
                <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
              </body>
            </html>
            
        2. Fichier calcul_pret.php
          • <!doctype html>
            <html lang="fr">
              <head>
                <!-- Required meta tags -->
                <meta charset="utf-8">
                <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
            
                <!-- Bootstrap CSS -->
                <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
            
                <title>Afficher le tableau multiplication</title>
                <style>
            fieldset {
            			border: 2px solid #dcdcdc;
            			border-radius: 10px;
            			padding: 10px 20px;
            			text-align: leftt;
            		}
                legend {
            		width:15%;
            		}    
            </style>
              </head>
              <body>
            <div class="container">
            </br>
            <?php
            if(isset($_POST["capital"])&&$_POST["taux"]&&$_POST["duree"])
            {
            $capital=$_POST["capital"];
            $taux=$_POST["taux"]/100/12;
            $duree=$_POST["duree"]*12;
            $assur=$_POST["assur"]*$capital*0.00035;
            $mens=($capital*$taux)/(1-pow((1+$taux),$duree));
            echo "<h3>Pour un prêt de $capital DT à ", $_POST["taux"] ,"%, sur ", $_POST["duree"]," ans la mensualité est de ",round($mens,2),"
            DT hors assurance</h3>";
            echo "<caption>Tableau d'amortissement du prêt</caption>";
            echo "<table class='table table-striped'>
            <tr><th>Mois </th><th>Capital restant</ th><th>
            Mensualité Hors Ass.</th><th>Amortissement </ th><th> Intérêt</th><th>
            Assurance</th><th>Mensualité Ass.cis </ th>";
            //Boucle d'affichage des lignes du tableau
            for($i=1;$i<=$duree;$i++)
            {
            $int=$capital*$taux;
            $amort=$mens-$int;
            echo "<tr>";
            echo "<td>$i</td>";
            echo "<td>",round($capital,2),"</td>";
            echo "<td>",round($mens,2),"</td>";
            echo "<td>",round($amort,2),"</td>";
            echo "<td>",round($int,2),"</td>";
            echo "<td>$assur</td>";
            echo "<td>",round($mens+$assur,2),"</td>";
            echo "</tr>";
            $capital=$capital-$amort;
            }
            echo "</table>";
            }
            else
            {
            header("Location:form4.php");
            
            }
            ?>
            </div>
            <!-- Optional JavaScript -->
                <!-- jQuery first, then Popper.js, then Bootstrap JS -->
                <script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
                <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
                <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
              </body>
            </html>
            
    5. Exercice 08

      1. Énoncé
      2. Solution
        1. Fichier fiche_renseignements.html
          • <!doctype html>
            <html lang="fr">
              <head>
                <!-- Required meta tags -->
                <meta charset="utf-8">
                <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
            
                <!-- Bootstrap CSS -->
                <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
            
                <title>Afficher le tableau multiplication</title>
                <style>
            fieldset {
            			border: 2px solid #dcdcdc;
            			border-radius: 10px;
            			padding: 10px 20px;
            			text-align: leftt;
            		}
                legend {
            		width:40%;
            		}    
            </style>
              </head>
              <body>
            <div class="container">
              <form method="post" action="fiche_renseignements.php" >
                <fieldset>
                  <legend>Recherche d'emploi:</legend>
                  <strong>Remplir la fiche</strong> 
                  <hr>
                  <div class="row">
                    <div class="col-sm-3">
                      <label for="ex1" >Prénom</label>
                      <input type="text" name="ident[]" class="form-control" />
                    </div>
                    <div class="col-sm-3">
                      <label for="ex2">Nom</label>
                      <input type="text" name="ident[]" class="form-control" />
                    </div>
                    <div class="col-sm-3">
                      <label for="ex3">Naissance</label>
                      <input type="date" name="ident[]" class="form-control"/>
                    </div>
                    <div class="col-sm-3">
                      <label for="ex3" >Email</label>
                      <input type="email" name="ident[]" class="form-control"/>
                    </div>
                  </div>      
                <div>
                  <hr>
                  <div class="row mt-2">
                    <div class="col-sm-4">
                      <strong>Langues pratiquées</strong><br />
                        <select name="lang[]" multiple="multiple" class="custom-select">
                        <option value="allemand"> Allemand</option>
                        <option value="anglais"> Anglais</option>
                        <option value="arabe"> Arabe</option>
                        <option value="espagnol"> Espagnol</option>
                        <option value="italien"> Italien</option>
                        <option value="français"> Français</option>
                      </select>
                    </div>
                  <div class="col-sm-8">
                      <strong>Compétences informatiques</strong><br />
                      <div class="form-check form-check-inline">
                        <label class="form-check-label">HTML 5</label>      
                        <input class="form-check-input ml-1" type="checkbox" name="competence[]" value="HTML 5" />
                      </div>
                      <div class="form-check form-check-inline">
                        <label class="form-check-label">CSS 3</label>      
                        <input class="form-check-input ml-1" type="checkbox" name="competence[]" value="CSS 3" />
                      </div>
                      <div class="form-check form-check-inline">
                        <label class="form-check-label">Javascript</label>      
                        <input class="form-check-input ml-1" type="checkbox" name="competence[]" value="Javascript" />
                      </div>
                      <div class="form-check form-check-inline">
                        <label class="form-check-label">jQuery</label>      
                        <input class="form-check-input ml-1" type="checkbox" name="competence[]" value="jQuery" />
                      </div>
                      <div class="form-check form-check-inline">
                        <label class="form-check-label">AJAX</label>      
                        <input class="form-check-input ml-1" type="checkbox" name="competence[]" value="AJAX" />
                      </div>
                      <div class="form-check form-check-inline">
                      <label class="form-check-label">PHP</label>
                      <input class="form-check-input ml-1" type="checkbox" name="competence[]" value="PHP" />
                    </div>
                    <div class="form-check form-check-inline">
                      <label class="form-check-label">MySQL</label>
                      <input class="form-check-input ml-1" type="checkbox" name="competence[]" value="MySQL" />
                    </div>
                    <div class="form-check form-check-inline">
                      <label class="form-check-label">JEE</label>      
                      <input class="form-check-input ml-1" type="checkbox" name="competence[]" value="JEE" />
                    </div>
                    <div class="form-check form-check-inline">
                      <label class="form-check-label">ASP.Net</label>
                      <input class="form-check-input ml-1" type="checkbox" name="competence[]" value="ASP.Net" />
                    </div>
                    </div> </div>
            <hr>
               <div class="row">
                <div class="col-sm-8">
                  <button type="reset" class="btn btn-primary" name="effacer">Effacer</button>
                  <button type="submit" class="btn btn-primary" name="envoyer">Envoyer</button>
                </div>
              </div>
            
            
            
              </fieldset>
              </form>
            
            </div>
            <!-- Optional JavaScript -->
                <!-- jQuery first, then Popper.js, then Bootstrap JS -->
                <script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
                <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
                <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
              </body>
            </html>
            
        2. Fichier fiche_renseignements.php
          • <!doctype html>
            <html lang="fr">
              <head>
                <!-- Required meta tags -->
                <meta charset="utf-8">
                <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
            
                <!-- Bootstrap CSS -->
                <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
            
                <title>Afficher le tableau multiplication</title>
                <style>
            fieldset {
            			border: 2px solid #dcdcdc;
            			border-radius: 10px;
            			padding: 10px 20px;
            			text-align: leftt;
            		}
                legend {
            		width:15%;
            		}    
            </style>
              </head>
              <body>
            <div class="container">
            </br>
            <?php
            function calcul_age($dteNaissance){
            $interval = date_diff(date_create(), date_create($dteNaissance));
            if($interval->format("%M")==00)
            {return $interval->format("  %Y ans, %d jours");
            
            
            }
            else{return $interval->format("  %Y ans, %M Mois, %d jours");
              
            }
            
            }
            if(isset($_POST["ident"]) && isset($_POST["lang"]) && isset($_POST["competence"]))
            {
            
            echo "<div class='row'>
                <div class='col-sm-6'>
                    <div class='card border-primary mb-4'>
                        <div class='card-header'>
                        <center><div style='width: 8rem;height: 8rem;'><img src='mes-images/apc_-161.png' class='card-img-top' alt='...'></div></center> </div>";
            
            //echo "<table border=\"1\"><tr><th> Récapitulatif de votre fiche d'information personnelle</th></tr><tr><td>";
            $prenom=$_POST["ident"][0];
            $nom=$_POST["ident"][1];
            $naissance=($_POST["ident"][2]);
            $age=calcul_age($naissance);
            $mail=($_POST["ident"][3]);
            $lang = $_POST["lang"];
            $competence=$_POST["competence"];
            echo "<div class='card-body'>";
            echo "<h5 class='card-title'>Vous êtes :<b> $prenom  ". stripslashes($nom)."</h5>";
            
            echo "</b><br />Vous êtes nés le <b>".date('d/m/Y',strtotime($naissance))."</b> , vous avez <b>$age</b> ";
            echo "<br />Votre adresse mail est :<b>$mail</b>";
            echo "<br />Vous parlez :";
            echo "<ul>";
            foreach($lang as $valeur)
            {
            echo " <li> $valeur </li>";
            }
            echo "</ul>";
            echo "Vous avez des compétences informatiques en :";
            echo "<ul>";
            foreach($competence as $valeur)
            {
            echo "<li> $valeur </li> ";
            }
            echo "</ul></div></div></div>";
            }
            else
            {
            echo"<script type=\"text/javascript\">" ;
            echo "alert('Cochez au moins une compétence!!');";
            echo "window.history.back();";
            echo "</script>";
            }
            ?>
            
            
            
            
            
            
            </div>
            <!-- Optional JavaScript -->
                <!-- jQuery first, then Popper.js, then Bootstrap JS -->
                <script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
                <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
                <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
              </body>
            </html>
            






    Riadh HAJJI

    Laisser un commentaire

    Abonnez vous à notre chaîne YouTube gratuitement