2016-03-19 5 views
-1

ich ein Problem mit meinem Code haben:

<header class="page-header"><h1>Ajouter une salle</h1></header> 
    <div class="container"> 
     <div class="jumbotron"> 
     <form action="creerSalle.php" method="get"> 
      <div class="form-group"> 
       <label for="numSalle">Numero salle :</label> 
       <input type="number" class="form-control" id="numSalle"/> 
      </div> 

      <div class="form-group"> 
       <label for="numEtage">Numero étage (0 pour RDC) :</label> 
       <input type="number" class="form-control" id="numEtage"/> 
      </div> 

      <div class="form-group"> 
       <label for="numBatiment">Numero bâtiment :</label> 
       <input type="number" class="form-control" id="numBatiment"/> 
      </div> 

      <div class="form-group"> 
       <label for="typeSalle">Type salle :</label> 
       <input type="text" class="form-control" id="typeSalle"/> 
      </div> 

      <div class="form-group"> 
       <label for="capacite">Capacite salle :</label> 
       <input type="range" class="form-control" id="capacite" min="1" max="100" onchange="updateTextInput(this.value);"/> 
       <input type="text" id="textInput" value="" class="textRange" disabled/> 
      </div> 

      <input type="submit" value="Valider"/> 

     </form> 

     <?php 
      ini_set('display_errors', 'On'); 
      error_reporting(E_ALL); 
      print_r($_GET); 

     if(!empty($_GET)) 
     { 

      $pdo = new PDO('mysql:host=localhost;dbname=projettutore', "root", ""); 
      $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); 
      $stmt = $pdo->prepare("INSERT INTO salle(id,numSalle,numEtage,numBatiment,typeSalle,capacite,nbOccupant) VALUES (?,?,?,?,?,?,0)"); 

      $stmt->bindParam(1,$_GET["numSalle"],PDO::PARAM_INT); 
      $stmt->bindParam(2,$_GET["numSalle"],PDO::PARAM_INT); 
      $stmt->bindParam(3,$_GET["numEtage"],PDO::PARAM_INT); 
      $stmt->bindParam(4,$_GET["numBatiment"],PDO::PARAM_INT); 
      $stmt->bindParam(5,$_GET["typeSalle"],PDO::PARAM_STR,20); 
      $stmt->bindParam(6,$_GET["capacite"],PDO::PARAM_INT); 

      if($pdo->exec($sql)){ 
       echo "Insertion réussie !"; 
      } 
      else 
       echo "ERROR !"; 
     } 

     ?> 

     </div> 
    </div> 

Die $ _GET Variable ist leer, und die URL hat keine? in ihm .. Ich habe keinen Fehler und es gibt keinen Einsatz in meiner Datenbank. Ich kann nicht herausfinden, was das Problem ist, also können Sie mir bitte helfen?

+1

enthalten müssen die 'setzen name' jeder der Eingangs-Tag-Attribut, so kann die get-Methode verstehen, was zu bekommen. –

Antwort

1

Mit $ _GET erfordert, dass das Eingabefeld ein Namensattribut hat, so dass anstelle von

<input type="number" class="form-control" id="numSalle"/> 

Sie

<input type="number" class="form-control" id="numSalle" name="numSalle"/> 
+0

Es hat funktioniert, danke! –

0

hinzufügen name Attribute tu Formular feilds haben würden.

 <input type="text" id="textInput" value="" class="textRange" name="FEILDNAME" disabled/> 

HINWEIS: Wenn u disabled-Attribut $_GET Variable hinzufügen nicht Wert dieses Feldes Sie