Enregistrement d'un formulaire

Fermé
pouching Messages postés 1 Date d'inscription vendredi 20 juin 2014 Statut Membre Dernière intervention 20 juin 2014 - Modifié par pijaku le 20/06/2014 à 14:11
pijaku Messages postés 12263 Date d'inscription jeudi 15 mai 2008 Statut Modérateur Dernière intervention 4 janvier 2024 - 20 juin 2014 à 14:10
j'aimerai k vous m'aidiez, j'ai un formulaire qui composé des listes déroulantes plus des zones de texte mais lors de l'enregistrement, ça ne passe bien. voici le code



<?php
    try
  {
   $bdd = new PDO('mysql:host=localhost;dbname=archive', 'root', '');
  }
   catch(Exception $e)
    {
     die('Erreur : '.$e->getMessage());
    }
    session_start(); // ici on continue la session
    if ((!isset($_SESSION['nom'])))
    {
  header('location:archive/index.php');
    exit();
    }
   
?>
<!DOCTYPE html>
<html dir="ltr" lang="en-US"><head><!-- Created by Artisteer v4.1.0.59861 -->
    <meta charset="utf-8">
    <title>Accueil</title>
    <meta name="viewport" content="initial-scale = 1.0, maximum-scale = 1.0, user-scalable = no, width = device-width">

    <!--[if lt IE 9]><script src="[https://html5shiv.googlecode.com/svn/trunk/html5.js]"></script><![endif]-->
    <link rel="stylesheet" href="../style.css" media="screen">
    <!--[if lte IE 7]><link rel="stylesheet" href="../style.ie7.css" media="screen" /><![endif]-->
    <link rel="stylesheet" href="../style.responsive.css" media="all">
    <link rel="stylesheet" type="text/css" href="ajout.css">


    <script src="../jquery.js"></script>
    <script src="../script.js"></script>
    <script src="../script.responsive.js"></script>


<style>.art-content .art-postcontent-0 .layout-item-0 { padding-right: 10px;  }
.art-content .art-postcontent-0 .layout-item-1 { padding-right: 10px;padding-left: 10px;  }
.art-content .art-postcontent-0 .layout-item-2 { padding-left: 10px;  }
.ie7 .art-post .art-layout-cell {border:none !important; padding:0 !important; }
.ie6 .art-post .art-layout-cell {border:none !important; padding:0 !important; }

</style></head>
<body>
<div id="art-main">
<header class="art-header">


    <div class="art-shapes">
<div class="art-object0" data-left="58.46%"></div>

            </div>




                        
                    
</header>
<nav class="art-nav">
    <div class="art-nav-inner">
    <ul class="art-hmenu">
        <li>
            <a href="../accueil.php" class="active">Accueil</a>
        </li>
        <li>
            <a href="./" class="">Documents</a>
                <ul class="">
                    <li><a href="../documents/ajouter.php" class="">Ajouter</a></li>
                    <li><a href="../documents/rechercher.php" class="">Rechercher</a></li>
                </ul>
        </li>
        <li>
            <a href="#" class="">Consultation</a>
                <ul class="">
                    <li><a href="../consultation/ajouter.php" class="">Ajouter</a></li>
                    <li><a href="../consultation/afficher.php" class="">Afficher</a></li>
                    <li><a href="../consultation/rechercher.php" class="">Rechercher</a></li>
                </ul>
        </li>
        <li>
            <a href="#">Classification</a>
                <ul class="">
      <li><a href="../classification/versement.php" class="">Versement</a></li>
      <li><a href="../classification/ranger.php" class="">Classification</a></li>
      <li><a href="../classification/afficher.php" class="">Afficher</a></li>
      <li><a href="../classification/rechercher.php" class="">Rechercher</a></li>
                </ul>
        <li><a href="#">Contact</a>
    <ul class="">
                        <li><a href="../compte/affiche_message.php" class="">Message</a></li>
                </ul>
  </li> 
  <li><a href="../deconnexion.php">Deconnexion</a></li></ul>
        </div>
    </nav>
          <div id="grdcadre">
                    <div id="titre">
                        <h2><b>Versement archive</b></h2>
                    </div>

                    <div id="formulaire">
                       <form method="POST" action="">
                              <table>
          <tr>
         <?php
          try
           {
            $bdd = new PDO('mysql:host=localhost;dbname=archive', 'root', '');
           }
            catch(Exception $e)
             {
             die('Erreur : '.$e->getMessage());
             }
         ?>
                                      <td><b>Type archive</b></td>
                                      <td>
          <select name="lib_type">
          <option value="" selected="selected">Choisir un type archive</option>
           <?php
 
            $reponse = $bdd->query('SELECT ID_TYPE,lib_type FROM type_archive');
 
            while ($donnees = $reponse->fetch())
            {
           ?>
           <option value="<?php echo $donnees['ID_TYPE']; ?>"> <?php echo $donnees['lib_type']; ?></option>
           <?php
            }
 
            ?>
            
         </select>
         </td>
          </tr>
                                  <tr>
                                      <td><b>Nom archive</b></td>
                                      <td><input type="text" name="TITRE_ARCHI" size=70 required="required"></td>
                                  </tr><br/>
                                  <tr>
                                      <td><b>cote</b></td>
                                      <td><input type="text" name="COTE_ARCHI" size=70 required="required"></td>
                                  </tr><br/>
          <tr>
         <?php
          try
           {
            $bdd = new PDO('mysql:host=localhost;dbname=archive', 'root', '');
           }
            catch(Exception $e)
             {
             die('Erreur : '.$e->getMessage());
             }
         ?>
                                      <td><b>Provenance</b></td>
                                      <td>
          <select name="LIBEL_SERV">
          <option value="" selected="selected">Choisir une provenance</option>
           <?php
 
            $reponse = $bdd->query('SELECT NUM_SERV, LIBEL_SERV FROM service');
 
            while ($donnees = $reponse->fetch())
            {
           ?>
           <option value="<?php echo $donnees['NUM_SERV']; ?>"> <?php echo $donnees['LIBEL_SERV']; ?></option>
           <?php
            }
 
            ?>
            
         </select>
         </td>
         </tr> <br/>
                                  <tr>
                                      <td><b>date d'enregistrement</b></td>
                                      <td><input type="date" name="annee_records" size=70 required="required"></td>
                                  </tr><br/>
                                 <br/><br/>  
                              </table>
                                      <input type="submit" name="uploader" value="Enregistrer" style="margin-left:220px;margin-top:30px;cursor:pointer">
                                      <input type="reset" name="annuler" value="Annuler" style="margin-left:20px;margin-top:30px;cursor:pointer">
                          </form>
                    </div>
                </div>         
               
<footer class="art-footer">
  <div class="art-footer-inner">
<div class="art-content-layout">
    <div class="art-content-layout-row">
    <div class="art-layout-cell layout-item-0" style="width: 100%">
        <p>Réseau des Aires Protégées d'Afrique Centrale (RAPAC)</p>
    </div>
    </div>
</div>

  </div>
</footer>

</div>


</body></html>

<?php

 if(isset($_POST['TITRE_ARCHI']) || isset($_POST['COTE_ARCHI']) || isset($_POST['annee_records']))
 {
  $TITRE_ARCHI = $_POST['TITRE_ARCHI'];
  $COTE_ARCHI = $_POST['COTE_ARCHI'];
  $annee_records = $_POST['annee_records'];

  //recuperation de la  piece jointe
   try
    {
     $bdd = new PDO('mysql:host=localhost;dbname=archive', 'root', '');
    }
     catch(Exception $e)
      {
       die('Erreur : '.$e->getMessage());
      }
  $bdd->exec("INSERT INTO 'archive' ('COTE_ARCHI', 'TITRE_ARCHI', 'annee_records')  VALUES('','$COTE_ARCHI', '$TITRE_ARCHI', '$annee_records')");
   echo '<body onLoad="alert(\'Enregistrement reussi...\')">';
   echo '<meta http-equiv="refresh" content="0;URL=versement.php">';
   //echo 'Enregistrement reussi';
}

?>
A voir également:

1 réponse

pijaku Messages postés 12263 Date d'inscription jeudi 15 mai 2008 Statut Modérateur Dernière intervention 4 janvier 2024 2 744
20 juin 2014 à 14:10
Bonjour,

Lorsque vous placez du code sur notre forum, merci d'utiliser les balises code à votre disposition.
Le mode d'emploi (au cas ou) est ICI.

Cordialement,
Pijaku
0