title: Data no inserted to database
body: <p>I am a beginner and trying to follow some tutorial videos for my school project. I am stuck when the data not inserted into the database. I double-check the code to tutorial and nothing wrong. There's no error message or notification too. I really appreciate your help. </p>
  
  <p>action.php</p>
  
  <pre><code> &lt;!--action.php--&gt;
      &lt;?php
          require 'config.php';
  
          if(isset($_POST['pid'])){
              $pid    = $_POST['pid'];
              $pname  = $_POST['pname'];      
              $pprice = $_POST['pprice'];
              $pimage = $_POST['pimage'];
              $pcode  = $_POST['pcode'];
              $pqty   = 1;
  
              $stmt = $conn-&gt;prepare("SELECT product_code FROM cart WHERE product_code=?");
              $stmt-&gt;bind_param("s",$pcode);
              $stmt-&gt;execute();
              $res = $stmt-&gt;get_result();
              $r = $res-&gt;fetch_assoc();
              $code = $r['product_code'];
  
              if(!$code){
                  $query = $conn-&gt;prepare("INSERT INTO cart (product_name,product_price,product_image,qty,total_price,produk_code) VALUES (?,?,?,?,?,?)");
                  $query-&gt;bind_param("sssiss",$pname,$pprice,$pimage,$pqty,$pprice,$pcode);
                  $query-&gt;execute();
  
                  echo '&lt;div class="alert alert-success alert-dismissible"&gt;
                          &lt;button type="button" class="close" data-dismiss="alert"&gt;&amp;times;&lt;/button&gt;
                          &lt;strong&gt;Item added to cart!&lt;/strong&gt; 
                        &lt;/div&gt;';      
              }
              else{
                  echo '&lt;div class="alert alert-success alert-dismissible"&gt;
                            &lt;button type="button" class="close" data-dismiss="alert"&gt;&amp;times;&lt;/button&gt;
                            &lt;strong&gt;Item already added to your cart!&lt;/strong&gt; 
                        &lt;/div&gt;';
              } 
          }
      ?&gt;
  </code></pre>
  
  <p>index.php</p>
  
  <pre><code>&lt;!--index.php--&gt;
  &lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
      &lt;title&gt;Map Store&lt;/title&gt;
      &lt;!-- Latest compiled and minified CSS --&gt;
      &lt;link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css"&gt;
      &lt;link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css"&gt;
      &lt;script src="https://kit.fontawesome.com/fc847822ba.js" crossorigin="anonymous"&gt;&lt;/script&gt;
  
      &lt;link rel="stylesheet" href="css/bootstrap.min.css" &gt;
  
      &lt;link rel="stylesheet" type="text/css" href="fontawesome/css/all.min.css"/&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;nav class="navbar navbar-expand-md bg-dark navbar-dark"&gt;
        &lt;!-- Brand --&gt;
        &lt;a class="navbar-brand" href="index.php"&gt;Map Store&lt;/a&gt;
  
        &lt;!-- Toggler/collapsibe Button --&gt;
        &lt;button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#collapsibleNavbar"&gt;
          &lt;span class="navbar-toggler-icon"&gt;&lt;/span&gt;
        &lt;/button&gt;
  
        &lt;!-- Navbar links --&gt;
        &lt;div class="collapse navbar-collapse" id="collapsibleNavbar"&gt;
          &lt;ul class="navbar-nav ml-auto"&gt;
            &lt;li class="nav-item"&gt;
              &lt;a class="nav-link active" href="index.php"&gt;Products&lt;/a&gt;
            &lt;/li&gt;
            &lt;li class="nav-item"&gt;
              &lt;a class="nav-link" href="#"&gt;Category&lt;/a&gt;
            &lt;/li&gt;
            &lt;li class="nav-item"&gt;
              &lt;a class="nav-link" href="cart.php"&gt;Checkout&lt;/a&gt;
            &lt;/li&gt;
            &lt;li class="nav-item"&gt;
              &lt;a class="nav-link" href="cart.php"&gt;&lt;i class="fas fa-shopping-cart text-white"&gt; &lt;span id="cart-item" class="badge badge-danger"&gt;0&lt;/span&gt; &lt;/i&gt;&lt;/a&gt;
            &lt;/li&gt;
  
          &lt;/ul&gt;
        &lt;/div&gt;
      &lt;/nav&gt;
      &lt;div class="container"&gt;
          &lt;div class="row mt-2"&gt;
              &lt;div id="message"&gt;
  
              &lt;/div&gt;
              &lt;?php
                  include 'config.php';
                  $stmt = $conn-&gt;prepare("SELECT * FROM product");
                  $stmt-&gt;execute();
                  $result = $stmt-&gt;get_result();
                  while($row = $result-&gt;fetch_assoc()):
              ?&gt;
              &lt;div class="col-lg-3"&gt;
                  &lt;div class="card-deck"&gt;
                      &lt;div class="card p-2 border-secondary mb-2"&gt;
                          &lt;img src="&lt;?= $row['product_image'] ?&gt;" class="card-img-top" height="250"&gt;
                          &lt;div class="card-body p-1"&gt;
                              &lt;h4 class="card-title text-center text-info"&gt;&lt;?= $row['product_name']?&gt;&lt;/h4&gt;
                              &lt;h5 class="card-text text-center text-danger"&gt;&lt;?= number_format($row
                                  ['product_price'],2) ?&gt;/-&lt;/h5&gt;
                          &lt;/div&gt;
                          &lt;div class="card-footer p-1"&gt;
                              &lt;form action="#" class="form-submit"&gt; 
                                  &lt;input type="hidden" class="pid" value="&lt;?= $row['id']?&gt;"&gt;
                                  &lt;input type="hidden" class="pname" value="&lt;?= $row['product_name']?&gt;"&gt;
                                  &lt;input type="hidden" class="pprice" value="&lt;?= $row['product_price']?&gt;"&gt;
                                  &lt;input type="hidden" class="pimage" value="&lt;?= $row['product_image']?&gt;"&gt;
                                  &lt;input type="hidden" class="pcode" value="&lt;?= $row['product_code']?&gt;"&gt;
                                  &lt;button class="btn btn-info btn-block addItemBtn"&gt;&lt;i class="fas fa-cart-plus "&gt;&lt;/i&gt;Add to cart&lt;/button&gt;
                              &lt;/form&gt;
  
                          &lt;/div&gt;
                      &lt;/div&gt;
                  &lt;/div&gt;
              &lt;/div&gt;
          &lt;?php endwhile; ?&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  
      &lt;!-- jQuery library --&gt;
      &lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"&gt;&lt;/script&gt;
  
      &lt;!-- Popper JS --&gt;
      &lt;script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"&gt;&lt;/script&gt;
  
      &lt;!-- Latest compiled JavaScript --&gt;
      &lt;script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"&gt;&lt;/script&gt;
      &lt;script type="text/javascript"&gt;
          $(document).ready(function(){
              $(".addItemBtn").click(function(e){
                  e.preventDefault();
                  var $form   = $(this).closest(".form-submit");
                  var pid     = $form.find(".pid").val();
                  var pname   = $form.find(".pname").val();
                  var pprice  = $form.find(".pprice").val();
                  var pimage  = $form.find(".pimage").val();
                  var pcode   = $form.find(".pcode").val();
  
                  $.ajax({
                      url: 'action.php',
                      method: 'post',
                      data: {pid:pid,pname:pname,pprice:pprice,pimage:pimage,pcode:pcode},
                      success:function(response){
                          $("message").html(response);
                      }
                  });
              });
          });
      &lt;/script&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>config.php</p>
  
  <pre><code>&lt;!--config.php--&gt;
  &lt;?php
      $conn = new mysqli("localhost","root","","checkout_system");
          if($conn-&gt;connect_error){
              die("Connection Failed!".$conn-&gt;connect_error);
          }
  ?&gt;
  </code></pre>
  
  <p>sorry i am new  here and this my first post</p>