Probléme de base données

Bonjour, j'ai un problème de base de donnée quand on remplit le formulaire d'inscription les information n'enregistrent pas dans la base de donnée ,
c'est le code

<?php

$nom=NULL;
$prenom=NULL;
$poids=NULL;
$age=NULL;
$poids=NULL;
$adresse=NULL;
$email=NULL;
$sexe=NULL;
$numtel=NULL;

if(isset($_POST['submit'])){

$nom=$_POST['nom'];
$prenom=$_POST['pnom'];
$age=$_POST['age'];
$poids=$_POST['poids'];
$adresse=$_POST['adresse'];
$email=$_POST['email'];
$sexe=$_POST['sexe'];
$numtel=$_POST['numtel'];

}

$connexion=mysql_connect("localhost","root","");
$bdd=mysql_select_db("aquagym");
$query="INSERT INTO membre (pnom,nom,age,poids,adresse,email,sexe,numtel) VALUES ('".$prenom."','".$nom."','".$age."','".$poids."','".$adresse."','".$email."','".$sexe."','".$numtel."')";
if(mysql_query($query,$connexion)){
echo "succes";
}else echo "walo";
mysql_close($connexion);

?>

<div id="footermainPan">
<div id="footerPan">
<ul class="templateworld">
<li>Design By:</li><br>
<li><a >Nada<br>Oumaima<br>Omayma</a></li>
</ul>
</div>
<br>

7 réponses

  1. Salut !

    Peux tu mettre ton formulaire stp :)

    Et fais un print_r($_POST) et dis moi ce que ca affiche :)
    0
    1. <html xmlns="http://www.w3.org/1999/xhtml"><head>
      <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />>
      <title>Aquagym</title>

      <link href="style.css" rel="stylesheet" type="text/css" />
      <style type="text/css">
      <!--
      form

      td, input, select, textarea
      { font-size:13px; font-family:tahoma,sans-serif; font-weight:bold; }
      input, select, textarea
      { color:#0099FF; }
      .passage, .champ
      { background-color:#F6F4E4 width:300px; }
      .choix
      { background-color:#F6F4E4; width:300px; }
      .cocher, .option
      { background-color:#F6F4E4; border:1px }
      .Bouton
      { background-img:images/morebg.gif; color:black; width:150px; height:50px }
      -->
      </style>
      </head>

      <body>
      <div id="mainPan">
      <div id="leftPan">
      <div id="leftTopPan">
      </div><br><br>
      <ul>
      <li><a href="index.php">Acceuil</a></li>
      <li><a href="tarifs.php">Tarifs</a></li>
      <li><a href="table.php">Séances</a></li>
      <li class="home">Inscription</li>
      </ul>
      <form action="contact.php" method="post">
      <h2>Contactez-nous:</h2>
      <label>Nom:</label>
      <input name="nom" id="votrenom" type="text" /> <br>
      <label>Prenom:</label>
      <input name="prenom" id="motdepasse" type="mot de passe" /><br>
      <input name="submit" class="button" value="Login" type="submit" />

      </form>

      </div><br><br />
      <br><br><br><br><br><br><br><br><br><br>
      <br>
      <div id="rightPan"><img align="left" src="image1.JPG" width=15% height=10% alt="photo"/><br>
      <h2><font face="Cambria" size="5" color=#0099FF>   Inscription en ligne:</b></font></h2>
      <br><br><br>
      <form action="mes.php"method="post" >
      <table border="0" cellpadding="3" cellspacing="0">
      <tr>

      <td align="right">Prenom:</td>
      <td><input name="pnom" type="text" class="champ" size="30" maxlength="100"/></td>
      </tr>
      <tr>
      <td align="right">Nom :</td>
      <td><input name="nom" type="text" class="champ" size="30" maxlength="100"/></td>
      </tr>
      <tr>
      <td align="right" valign="top">Sexe:</td>
      <td>
      <input type="radio" class="option" name="sexe" value="m"/> Homme<br>
      <input type="radio" class="option" name="sexe" value="w"/>Femme
      </td>
      </tr>
      <tr>
      <td align="right">Age :</td>
      <td><input name="age" type="text" class="champ" size="30" maxlength="40"/></td>
      </tr>
      <tr>
      <td align="right">Poids :</td>
      <td><input name="poids" type="text" class="champ" size="30" maxlength="40"/></td>
      </tr>
      <tr>
      <td align="right">Tel:</td>
      <td><input name="numtel" type="text" class="champ" size="30" maxlength="40"/></td>
      </tr> <tr>
      <td align="right">E-mail:</td>
      <td><input name="email" type="text" class="champ" size="30" maxlength="40"/></td>
      </tr>
      <tr>
      <td align="right">Adresse:</td>
      <td><input name="adresse" type="text" class="champ" size="30" maxlength="40"/></td>
      </tr>
      <tr>
      <td align="right" valign="top">caracteristiques:</td>
      <td>
      <select name="caracteristique" class="choix" size="1">
      <option value="...">Diabétique</option>
      <option value="..">Asthmatique</option>
      <option value="...">Autre</option>
      <option value="...">aucun </option>
      </select>
      </td>
      </tr>
      </tr><tr>
      <td align="right" valign="top">Activites:</td>
      <td>
      <select name="idact" class="choix" size="1">
      <option value=Aerobic">Aerobic</option>
      <option value="Fitness">Fitness</option>
      <option value="aquagym">aquagym</option>
      <option value="dance">Dance</option>
      </select>
      </td>
      </tr><tr>
      <td align="right" valign="top">Commentaire:</td>
      <td><textarea name="Text" class="passage" rows="10" cols="50"></textarea></td>
      </tr>
      <tr><td align="right"></td>
      <td>

      <td>
      <input type="submit" class="Bouton" value="S'inscrire" name="submit"/>

      </td>
      </tr>

      </table>

      </form><br></p>
      <br><br><br><br><br>
      </div>

      <?php

      $nom=NULL;
      $prenom=NULL;
      $poids=NULL;
      $age=NULL;
      $poids=NULL;
      $adresse=NULL;
      $email=NULL;
      $sexe=NULL;
      $numtel=NULL;

      if(isset($_POST["submit"])){

      $nom=$_POST['nom'];
      $prenom=$_POST['pnom'];
      $age=$_POST['age'];
      $poids=$_POST['poids'];
      $adresse=$_POST['adresse'];
      $email=$_POST['email'];
      $sexe=$_POST['sexe'];
      $numtel=$_POST['numtel'];

      }

      $connexion=mysql_connect("localhost","root","");
      $bdd=mysql_select_db("aquagym");
      $query="INSERT INTO membre (pnom,nom,age,poids,adresse,email,sexe,numtel) VALUES ('".$prenom."','".$nom."','".$age."','".$poids."','".$adresse."','".$email."','".$sexe."','".$numtel."')";
      print_r($_POST);
      if(mysql_query($query,$connexion)){
      echo "succes";
      }else echo "echec";
      mysql_close($connexion);

      ?>

      <div id="footermainPan">
      <div id="footerPan">
      <ul class="templateworld">
      <li>Design By:</li><br>
      <li><a >Nada<br>Oumaima<br>Omayma</a></li>
      </ul>
      </div>
      <br>

      </div>

      </body></html>
      0
      1. Donc ton formulaire n'envois aucune valeur.

        Tu as deux form, et une multitude de petites erreurs HTML.
        Donc quel form veux tu envoyé ?

        Petit rêgle de base :

        <input type="text" name="nom">
        En php on récupère $_POST['nom'], ET il faut TOUJOURS vérifier son contenu de la manière suivante :
        if(isset$($_POST['nom']) && !empty($_POST['nom']))
        {
        // On fait le code
        }

        Si tu précise une value, c'est ce que tu vas récupéré en $_POST['monInput']

        A surtout éviter /!\ : les espaces et caractères avec des accents dans les attribut html !

        0
        1. <option value="Aerobic">Aerobic</option>

          Aucune value, normal ??
          <option value="...">Diabétique</option>
          <option value="..">Asthmatique</option>
          <option value="...">Autre</option>
          <option value="...">aucun </option>

          Dans le php :

          if(isset($_POST['pnom']) && !empty($_POST['pnom']) && isset($_POST['nom']) && !empty($_POST['nom']) && isset($_POST['poids']) && !empty($_POST['poids']) && isset($_POST['age']) && !empty($_POST['age']) && isset($_POST['sexe']) && !empty($_POST['sexe']) && isset($_POST['email']) && !empty($_POST['email']) && isset($_POST['adresse']) && !empty($_POST['adresse']) && isset($_POST['numtel']) && !empty($_POST['numtel']))
          {
          $nom=$_POST['nom'];
          $prenom=$_POST['pnom'];
          $age=$_POST['age'];
          $poids=$_POST['poids'];
          $adresse=$_POST['adresse'];
          $email=$_POST['email'];
          $sexe=$_POST['sexe'];
          $numtel=$_POST['numtel'];

          $connexion=mysql_connect("localhost","root","");
          $bdd=mysql_select_db("aquagym");
          $query="INSERT INTO membre (pnom,nom,age,poids,adresse,email,sexe,numtel) VALUES ('".$prenom."','".$nom."','".$age."','".$poids."','".$adresse."','".$email."','".$sexe."','".$numtel."')";
          print_r($_POST);
          if(mysql_query($query,$connexion)){
          echo "succes";
          }else echo "echec";
          mysql_close($connexion);

          }

          0
          1. malheuresement ca marche pa mais merciiii beaucoup et désolé pour le dérongement :)
            0