我无法在我的数据库中插入数据。我哪里错了?

时间:2016-01-21 08:23:52

标签: php mysql sql pdo localhost

这是我的代码。我正在使用php 5.4和PDO连接! 我包括我的数据库连接和我需要的其他一些文件。现在我有一个注册表单,我添加了一些填充它们的值。制定了方向,并没有显示问题。但是当我检查数据库没有添加时。我哪里错了?

代码

 <?php
 include'db.php';
 include'header.php';
 require 'vendndodhje.php';

 $VendndodhjeInput = new Vendndodhje();

 if ( !empty($_POST)) {
 // keep track validation errors
 $emerError = null;
 $mbiemerlError = null;
    $dtlError = null;
    $telError = null;
    $emailError = null;
    $vendndodhjeError=null;

    // keep track post values
    $emer = $_POST['emer'];
    $mbiemer = $_POST['mbiemer'];
    $datelindje = $_POST['datelindje'];
    $tel = $_POST['tel'];
    $email = $_POST['email'];
    $Vendndodhje=$_POST['Vendndodhje'];

    //insert values

 if ($valid) {
  $pdo = Database::connect();
   $sql = "INSERT INTO klienti(emer,mbiemer,datelindje,tel,email,Vendndodhje,date_aplikimi) VALUES(?, ?, ?, ?, ?, ?, NOW())";
    $q = $pdo->prepare($sql);
    $q->execute(array($emer, $mbiemer, $datelindje, $tel,$email, $Vendndodhje));
    }
  header("Location: form'.php");
 }
?>

2 个答案:

答案 0 :(得分:1)

您可以尝试这样的事情:

$(document).ready(function($) {
  $('#accordion').find('.accordion-toggle').click(function() {
    //Expand or collapse this panel
    $(this).next().slideToggle(500);
    //Hide the other panels
    $(".accordion-content").not($(this).next()).slideUp(1000);
    
    $(".active").removeClass("active");
    
    $("#accordion")
      .find(".glyphicon")
      .removeClass("glyphicon-remove-circle")
      .addClass("glyphicon-plus-sign")
    
    $(this)
      .addClass("active")
      .find('.glyphicon')
      .removeClass("glyphicon-plus-sign")
      .addClass("glyphicon-remove-circle")
  });
});
.active > .glyphicon{
  color:orange;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>

<link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css"/>

<div id="accordion">
  <h4 class="accordion-toggle active">
    <span class="glyphicon glyphicon-remove-circle"></span> 
    Wise busy ast both park when an ye no Nay likely her</h4>
  <div class="accordion-content default">
    <p>
      Cras malesuada ultrices augue molestie risus.</p>
  </div>
  <h4 class="accordion-toggle">
    <span class="glyphicon glyphicon-plus-sign">  </span> 
    Written enquire painful ye to offuces forming it</h4>
  <div class="accordion-content">
    <p>
      Lorem ipsum dolor sit amet mauris eu turpis.</p>
  </div>
  <h4 class="accordion-toggle">
    <span class="glyphicon glyphicon-plus-sign">  </span>
    In finished on he speaking suitable advanced if happines</h4>
  <div class="accordion-content">
    <p>
      Vivamus facilisisnibh scelerisque laoreet.</p>
  </div>
  <h4 class="accordion-toggle">
    <span class="glyphicon glyphicon-plus-sign"> </span> 
    People as period twenty my extent as Set was better</h4>
  <div class="accordion-content">
    <p>
      Vivamus facilisisnibh scelerisque laoreet.</p>
  </div>
</div>

答案 1 :(得分:0)

将类添加到<span class="glyphicon glyphicon-plus-sign MyIcon">,然后添加css MyIcon:active{background:orange;}