File manager - Edit - /home/custbahd/public_html/webs/monitor/clients/marylhouse/index/checkout/index.php
Back
<?php if(isset($_POST['submit'])) { $host="localhost";//host name $username="root"; //database username $password="";//database word $db_name="custbahd_customassist";//database name $tbl_name="checkout"; //table name $con=mysqli_connect("$host", "$username", "$password","$db_name")or die("cannot connect");//connection string $fname = $_POST['fname']; $lname = $_POST['lname']; $region = $_POST['region']; $image = $_POST['image']; $area = $_POST['area']; $street = $_POST['street']; $phone = $_POST['phone']; $email = $_POST['email']; $subtotal = $_POST['subtotal']; $delivery = $_POST['delivery']; $discount = $_POST['discount']; $total = $_POST['total']; $name1=$_POST['name']; $name2=""; $type1 = $_POST['type']; $type2=""; $quantity1=$_POST['quantity']; $quantity2=""; $price1=$_POST['price']; $price2=""; foreach($name1 as $name3) { $name2 .= $name3.","; } foreach($type1 as $type3) { $type2 .= $type3.","; } foreach($quantity1 as $quantity3) { $quantity2 .= $quantity3.","; } foreach($price1 as $price3) { $price2 .= $price3.","; } $in_ch=mysqli_query($con,"insert into checkout(name,type,fname,lname,region,quantity,price,image,area,street,phone,email,subtotal,delivery,discount,total) values ('$name2','$type2','$fname','$lname','$region','$quantity2','$price2','$image','$area','$street','$phone','$email','$subtotal','$delivery','$discount','$total')"); if($in_ch==1) { echo'<script>alert("Inserted Successfully")</script>'; } else { echo'<script>alert("Failed To Insert")</script>'; } } ?> <?php //including the database connection file include_once("config.php"); //fetching data in descending order (lastest entry first) //$result = mysql_query("SELECT * FROM users ORDER BY id DESC"); // mysql_query is deprecated $result = mysqli_query($mysqli, "SELECT * FROM checkout ORDER BY id ASC"); // using mysqli_query instead ?> <?php session_start(); require_once("../db/dbcontroller.php"); $db_handle = new DBController(); if(!empty($_GET["action"])) { switch($_GET["action"]) { case "add": if(!empty($_POST["quantity"])) { $productByCode = $db_handle->runQuery("SELECT * FROM shop WHERE code='" . $_GET["code"] . "'"); $itemArray = array($productByCode[0]["code"]=>array('name'=>$productByCode[0]["name"], 'code'=>$productByCode[0]["code"], 'type'=>$productByCode[0]["type"], 'quantity'=>$_POST["quantity"], 'price'=>$productByCode[0]["price"], 'image'=>$productByCode[0]["image"])); $productByCode = $db_handle->runQuery("SELECT * FROM home_products WHERE code='" . $_GET["code"] . "'"); $itemArray = array($productByCode[0]["code"]=>array('name'=>$productByCode[0]["name"], 'code'=>$productByCode[0]["code"], 'type'=>$productByCode[0]["type"], 'quantity'=>$_POST["quantity"], 'price'=>$productByCode[0]["price"], 'image'=>$productByCode[0]["image"])); if(!empty($_SESSION["cart_item"])) { if(in_array($productByCode[0]["code"],array_keys($_SESSION["cart_item"]))) { foreach($_SESSION["cart_item"] as $k => $v) { if($productByCode[0]["code"] == $k) { if(empty($_SESSION["cart_item"][$k]["quantity"])) { $_SESSION["cart_item"][$k]["quantity"] = 0; } $_SESSION["cart_item"][$k]["quantity"] += $_POST["quantity"]; } } } else { $_SESSION["cart_item"] = array_merge($_SESSION["cart_item"],$itemArray); } } else { $_SESSION["cart_item"] = $itemArray; } } break; case "remove": if(!empty($_SESSION["cart_item"])) { foreach($_SESSION["cart_item"] as $k => $v) { if($_GET["code"] == $k) unset($_SESSION["cart_item"][$k]); if(empty($_SESSION["cart_item"])) unset($_SESSION["cart_item"]); } } break; case "empty": unset($_SESSION["cart_item"]); break; } } ?> <!DOCTYPE html> <html lang="en" class="no-js"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>Check Out</title> <!-- Favicon --> <link rel="icon" href="../logo/glass3.png"> <link rel="stylesheet" type="text/css" href="css/bootstrap.min.css" /> <link rel="stylesheet" type="text/css" href="css/et-lineicon.css" /> <link rel="stylesheet" type="text/css" href="css/font-awesome.min.css" /> <link rel="stylesheet" type="text/css" href="css/pulsate.css"> <link rel="stylesheet" type="text/css" href="css/bounce.css"> <link href='http://fonts.googleapis.com/css?family=Roboto:400,500,400italic,500italic,700' rel='stylesheet' type='text/css'> <!--[if IE]> <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script> <![endif]--> <style type="text/css"> body { background-image: url('../gif/gif29.gif'); background-position: center; background-size: cover; background-repeat: no-repeat; } .top { font-size: 16px; color: white; text-align: center; margin: 20px; } .top span { font-weight: bolder; color: dodgerblue; } /*Table*/ .table { max-width: 100% !important; min-width: 50%; border-radius: 10px; background-color: rgba(23, 24, 24, 0.3); -webkit-box-shadow: 0px 5px 12px -12px rgba(0, 0, 0, 0.29); -moz-box-shadow: 0px 5px 12px -12px rgba(0, 0, 0, 0.29); box-shadow: 0px 5px 12px -12px rgba(0, 0, 0, 0.29); } .table thead.thead-primary { border-radius: 4px; } .table thead th { border: none; padding: 30px; font-size: 20px; font-weight: 500; color: dodgerblue; } .table tbody tr { margin-bottom: 10px; } .table tbody th, .table tbody td { border: none; padding: 30px; border-bottom: 1px solid rgba(255, 255, 255, 0.1); vertical-align: middle; } .table tbody td.quantity { width: 10%; } .table tbody td .img { width: 70px; } .table tbody td .email span { display: block; } .table tbody td .email span:first-child { font-weight: 500; font-size: 20px; color: white; } .table tbody td .email span :last-child{ color: dodgerblue; } .table tbody td span { color: dodgerblue; } .table tbody td strong { color: white; } .cart-wrap .btn-primary { display: block; width: 100%; } .cart-total { width: 100%; display: block; color: white; margin-top: 10px; margin-bottom: 10px; border: 1px solid rgba(0, 0, 0, 0.05); border-radius: 10px; background-color: rgba(23, 24, 24, 0.3); padding: 20px; } .cart-total h3 { font-size: 24px; margin-bottom: 20px; font-weight: 500; } .cart-total p { width: 100%; display: block; } .cart-total p span { display: block; width: 50%; } .cart-total p.total-price span { text-transform: uppercase; } .cart-total p.total-price span:last-child { color: white; font-weight: 600; } .cart-total hr { background: rgba(255, 255, 255, 0.1); } .home { font-weight: bold; text-align: center; } .home a{ text-decoration: none; color: white; padding: 10px; border-radius: 18px; background-color: rgba(23, 24, 24, 0.6); } </style> </head> <body> <div class="top"> Thank You <span><?php echo $lname;?>,</span> We've received your order as below:</div> <section class="ftco-section"> <div class="container"> <div class="row"> <div class="table-wrap"> <table class="table"> <thead class="thead-primary"> <tr> <th>Image</th> <th>Product</th> <th>Price</th> <th>Quantity</th> <th>Total</th> </tr> </thead> <tbody> <?php if(isset($_SESSION["cart_item"])){ $total_quantity = 0; $total_price = 0; ?> <?php foreach ($_SESSION["cart_item"] as $item){ $item_price = $item["quantity"]*$item["price"]; ?> <tr class="alert" role="alert"> <td> <div class="img"> <?php echo "<img src='../admin/shop/images/".$item['image']."' width='100%'>"; ?></div> </td> <td> <div class="email"> <span><?php echo $item["name"]; ?></span> <span><?php echo $item["type"]; ?></span> </div> </td> <td><span><?php echo "UGX ". number_format ($item["price"]); ?></span></td> <td><span><?php echo $item["quantity"]; ?></span></td> <td> <strong><?php echo "UGX ". number_format ($item_price); ?></strong> </td> </tr> <?php $total_quantity += $item["quantity"]; $total_price += ($item["price"]*$item["quantity"]); } ?> <?php } else { ?> <!--Cart when empty--> <td> Your Cart is Empty </td> <td><a href="all_products.php">Go Shopping</a></td> </div> <!--Cart when empty end--> <?php } ?> </tbody> </table> </div> </div> <div> <div class="col col-lg-5 col-md-6 mt-5 cart-wrap ftco-animate"> <div class="cart-total mb-3"> <div style="color: dodgerblue;text-align: center;">This is your total payment, wait for our call</div> <h3>Cart Totals</h3> <!--Cart totals--> <?php if(isset($_SESSION["cart_item"])){ $total_quantity = 0; $total_price = 0; $total_amount = 0; ?> <?php foreach ($_SESSION["cart_item"] as $item){ $item_price = $item["quantity"]*$item["price"]; ?> <?php $total_quantity += $item["quantity"]; $total_price += ($item["price"]*$item["quantity"]); $total_amount = ($total_price+5000); } ?> <p class="d-flex"> <span>Subtotal</span> <span><?php echo "UGX ". number_format ($total_price); ?></span> </p> <p class="d-flex"> <span>Delivery</span> <span>UGX 5,000</span> </p> <p class="d-flex"> <span>Discount</span> <span>UGX 0.00</span> </p> <hr> <p class="d-flex total-price"> <span>Total</span> <span><?php echo "UGX ". number_format ($total_amount); ?></span> </p> </div> <?php } else { ?> <!-- Cart total without quantity--> <span>No Results</span> <a href="all_products.php">Go Shopping</a> <!--Cart total quantity end--> <?php } ?> </div> </div> </div> <div class="home"><a href="../index.php?action=empty">Back Home</a></div> </section> </body> </html>
| ver. 1.4 |
Github
|
.
| PHP 8.1.33 | Generation time: 2.25 |
proxy
|
phpinfo
|
Settings