jamesmva

Untitled

Oct 26th, 2016
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.81 KB | None | 0 0
  1. include_once '../incluedes/conn_cms.php';//session started here
  2.  
  3.          if(isset($_POST['submit_post'])){
  4.            
  5.  
  6.             $date = date('Y-m-d');
  7.             $size = isset($_POST['size']) ? $_POST['size'] :  array();
  8.             $numero = isset($_POST['numero']) ? $_POST['numero'] :  array();
  9.             $vari = isset($_POST['vari']) ? $_POST['vari'] :  array();
  10.             $desenho = isset($_POST['desenho']) ? $_POST['desenho'] :  array();
  11.             $fabrics= isset($_POST['fabric']) ? $_POST['fabric'] :  array();
  12.             $size = isset($_POST['size']) ? $_POST['size'] :  array();
  13.             $qnty = isset($_POST['qnty']) ? $_POST['qnty'] :  array();
  14.             $cost = isset($_POST['cost']) ? $_POST['cost']:  array();
  15.             $subtotal = isset($_POST['subtotal']) ? $_POST['subtotal'] :  array();
  16.             $total = isset($_POST['total']) ? $_POST['total'] :  array();
  17.             $all_products = isset($_POST['all_products']) ? $_POST['all_products'] :  array();
  18.            
  19.  
  20.             $pedido=$date." ".$_SESSION['userName']."-".$_SESSION['userLName'];
  21.  
  22.             foreach ($fabrics as $fabric)
  23.          {
  24.      
  25.             $index = array_search($fabric, $fabrics);
  26.  
  27.             $query = "SELECT * FROM almofadas WHERE id_price='$fabrics[$index]'";
  28.             $result = mysqli_query($conn,$query);
  29.             while($rows = mysqli_fetch_assoc($result)){
  30.             $tecido=$rows['tecido']; //
  31.             }
  32.  
  33.  
  34.                    $ins_sql = "INSERT INTO orders (fabric,size,product_quantity,order_id,product_img,product_title,variante,product_cost,product_subtotal)
  35.                    VALUES ('$tecido', '$size[$index]' , '$qnty[$index]', '$pedido', '$desenho[$index]', '$numero[$index]', '$vari[$index]', '$cost[$index]', '$subtotal[$index]')";
  36.                  
  37.                   if ($conn->query($ins_sql) === TRUE) {
  38.                       echo "New record created successfully";
  39.                      } else {
  40.                       echo "Error: " ;
  41.                     }
  42.                
  43.             }
  44.  
  45.             $conn->close();
  46.             unset($_SESSION['Products_cart']);  
  47.  
  48.  }
Advertisement
Add Comment
Please, Sign In to add comment