File manager - Edit - /home/custbahd/public_html/webs/monitor/clients/marylhouse/index/checkout/indexer.php
Back
<?php if(isset($_POST['submit'])) { $host="localhost";//host name $username="root"; //database username $password="";//database word $db_name="maryl";//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("../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 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"])); $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> <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/style.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"> #home .large-header { background: black; background-image: url("../images/pattern.png"); background-position: center; background-size: cover; background-repeat: no-repeat; } body, html { height: 100%; margin: 0; } .bgimg { background-image: url("pattern.png"); height: 100%; background-position: center; background-size: cover; position: relative; color: white; font-family: "Courier New", Courier, monospace; font-size: 25px; } .topleft { position: absolute; top: 0; left: 16px; } .bottomleft { position: absolute; bottom: 0; left: 16px; } .middle { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); text-align: center; } hr { margin: auto; width: 40%; } #demo { color: white; } #logo{ position: absolute; width: 100%; top: 10%; left: 20%; width: 100%; text-align: center; } #logo img{ width: 40%; } #logo p{ color: white; font-size: 30px; font-weight: bold; } #logo b{ text-align: center; color: white; font-size: 30px; font-weight: bold; } .row span { color: dodgerblue; } .row p{ color: silver; } .home-main { position: absolute; width: 100%; text-align: center; top: 50%; left: 20%; -webkit-transform: translate3d(-50%,-50%,0); transform: translate3d(-50%,-50%,0); } </style> </head> <body> <!-- Preloader --> <div class="animationload"> <div class="loader"> Loading... </div> </div> <!-- End Preloader --> <!-- ========================= HOME ========================== --> <section id="home"> <div class="content"> <div class="row"> <div id="logo"> <b>Thank You <a href="#"><?php echo $lname;?></a></b> </div> </div> <div id="large-header" class="large-header"> <canvas id="demo-canvas"></canvas> <div id="countdown_dashboard" class="home-main container"> <div class="row"> <?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"]; ?> <div class="img"> <?php echo "<img src='../image/".$item['image']."' width='20%'>"; ?></div> <div class="email"> <span><?php echo $item["name"]; ?></span> <span><?php echo $item["type"]; ?></span> </div> <div class="input-group"> <?php echo $item["quantity"]; ?> </div> <strong><?php echo "UGX ".($item_price); ?></strong> <?php $total_quantity += $item["quantity"]; $total_price += ($item["price"]*$item["quantity"]); } ?> <?php } else { ?> <!--Cart when empty--> <?php } ?> <!--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 ".($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 ".($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 } ?> <p>Your Order has been received, wait for our call in a few</p> <p><a href="../index.php?action=empty">Back Home</a></p> </div> </div> </div> </section> <!-- JAVASCRIPTS --> <script src="js/jquery.min.js"></script> <script src="js/jquery.lwtCountdown-1.0.js"></script> <script src="js/jquery.stellar.min.js"></script> <script src="js/jquery.nicescroll.min.js"></script> <script src="js/animated.js"></script> <script src="js/main.js"></script> </body> </html>
| ver. 1.4 |
Github
|
.
| PHP 8.1.33 | Generation time: 2 |
proxy
|
phpinfo
|
Settings