File "placeOrder.php"
Full Path: /home/krishnamexports/public_html/ajax/placeOrder.php
File size: 2.59 KB
MIME-type: text/x-php; charset=us-ascii
Charset: utf-8
<?php
session_start();
error_reporting(0);
include("../config/database.php");
$orderDate = date('Y-m-d');
$name = mysqli_real_escape_string($cn,$_POST['name']);
$mobile = mysqli_real_escape_string($cn,$_POST['mobile']);
$email = mysqli_real_escape_string($cn,$_POST['email']);
$notes = mysqli_real_escape_string($cn,$_POST['notes']);//mysqli_real_escape_string($cn,$_POST['address']);
$address = "";//mysqli_real_escape_string($cn,$_POST['address']);
$country = mysqli_real_escape_string($cn,$_POST['country']);
$city = mysqli_real_escape_string($cn,$_POST['city']);
$landmark = "";//mysqli_real_escape_string($cn,$_POST['landmark']);
$alt_mobile = "";//mysqli_real_escape_string($cn,$_POST['alt_mobile']);
$orderId = 1;
$sqlReg = mysqli_query($cn, "select max(order_id) from `tbl_order`");
if(mysqli_num_rows($sqlReg)>0)
{
$sqlRegData = mysqli_fetch_array($sqlReg);
$orderId = $sqlRegData['max(order_id)']+1;
}
if(isset($_SESSION['kxproductList']) && count($_SESSION['kxproductList'])>0)
{
$subTotal = 0; $deliveryCharges = 0; $orderTotal = 0; $loop = 0;
$loop = 0;
foreach($_SESSION['kxproductList'] as $pL)
{
$remark = ""; $sizeId = ""; $polishId = "";
$sqlProductCart = mysqli_query($cn,"select * from `tbl_product` where `id`='".$pL['productId']."'");
$sqlProductCartData = mysqli_fetch_array($sqlProductCart);
if(isset($_SESSION['adInfo'])){ $remark = $_SESSION['adInfo'][$loop];}
if(!empty($pL['sizeId'])){
$sizeId = sizeName($pL['sizeId']);
}
if(!empty($pL['polishId'])){
$polishId = polishName($pL['polishId']);
}
$sqlOrder = mysqli_query($cn, "INSERT INTO `tbl_order` SET `order_date`='".$orderDate."', `order_id`='".$orderId."', `customer_id`=' ', `product_id`='".$pL['productId']."', `size`='".$sizeId."', `polish`='".$polishId."', `product_name`='".$sqlProductCartData['name']."', `price`=0, `qty`='".$pL['qty']."', `total`=0, `delivery_charge`=0, `order_total`=0, `remark`='".$remark."', `notes`='".$notes."', `discount_amount`=0, `status`=0, `name`='".$name."', `phone`='".$mobile."', `email`='".$email."', `address`='".$address."', `country`='".$country."', `city`='".$city."', `landmark`='".$landmark."', `alternate_mobile`='".$alt_mobile."', `date`=Now()");
}
$arr = array('status'=>true, 'orderId'=>$orderId);
unset($_SESSION['kxproductList']);
unset($_SESSION['adInfo']);
}
else
{
$_SESSION['placeError'] = "Somthing Went Wrong Try Again.";
$arr = array('status'=>false);
}
echo json_encode($arr);
?>