Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <title>BuySpace!</title>
- <meta charset="UTF-8">
- <link rel="stylesheet" type="text/css" href="main.css">
- <?php
- ini_set("display_errors", "on");
- // include "basketscript.php";
- // PHP login
- $username = 'c1626152';
- $password = 'aip7frashk';
- $host = 'csmysql.cs.cf.ac.uk';
- $dbname = 'c1626152';
- // Connection PHP
- $connector = new mysqli($host,$username,$password,$dbname)
- or die("Unable to connect right now!");
- echo "Connection successful"; //
- // ===Security script to stop potential MySQL exploit===
- // if(!isset ($_COOKIE['BuySpace.com'])) {
- // header('location: ./emptyPage.html');
- // exit;
- // }
- // This script only allows to view the basket items
- $sql = "SELECT * FROM MyGuests WHERE id='".$_SESSION['customer']."'";
- $sql2 = "SELECT * FROM products WHERE id='".$_SESSION['Basket']."'";
- ?>
- </head>
- <body>
- <div class="mainbuttons-div" id="mainbuttons-div">
- <div class="logodiv">
- <a href="./home.php">
- <img class='logo' src="logo.jpg"/>
- </a>
- </div>
- </div>
- <!-- Menu created with help from https://www.w3schools.com/howto/howto_css_dropdown.asp -->
- <nav><div id = 'menu'> <!-- Menu divider -->
- <div class="dropdown-div"> <!-- shape button with this -->
- <button class="dropdown-btn"><img src="menu-btn.png" class="btn-img"/></button> <!-- Button itself -->
- <div class="dropdown-content">
- <a href="./home.php">Home</a>
- <a href="./emptyPage.html">About</a>
- <a href="./contact.html">Contact</a>
- </div>
- </div>
- <div class="basketdiv">
- <button onclick="location.href='./basket.php'" class="basket-btn" id="basket">
- <img src="shoppingCart.png" class="basket-img">
- </button>
- </div>
- </div>
- </nav>
- <!-- Main page code -->
- <div class = "basket-contents-div">
- <h2>Basket</h2>
- <?php
- print '<h2>Your Shopping Cart:</h2>';
- foreach ($_SESSION['basket'] as $key =>$quantity){
- print '<p class = "php_text">The Product ID: '.$_SESSION['id'].' </p>';
- }
- print '<p class = "php_text"> total cost: '$_SESSION['total'];
- print '<p class = "php_text"> Quantity: '.$_SESSION['quantity'].' </p>';
- // if ($returned = mysql_query($sql, $connector)) {
- // while ($row = mysql_fetch_array($returned)) {
- // print '<p class = "php_text"><b>Product Name: {'$row["name"]'}<br />
- // The Price: {'$row["price"]'}<br />
- // </p><hr />\n';
- // }
- // }
- ?>
- <form action="./pay.php">
- <input type="submit" value="confirm & Pay" class="pay-btn" /></div>
- </form>
- </div>
- ========================================================================================================================================
- BASKETSCRIPT.PHP
- <?php
- ini_set("display_errors", "on");
- // get customer ID to link to basket
- $_SESSION['basket'] = array('id'=>$product['id'], 'quantity'=>$quantity);
- $quantity = count($_SESSION['basket'])); //<====== Possible error on count() function
- print_r("Current basket: ",$_SESSION['basket']);
- // $row = foreach($_SESSION['products'] AS $product){
- // print $product["name"];
- // }
- // PHP login
- $username = 'c1626152';
- $password = 'aip7frashk';
- $host = 'csmysql.cs.cf.ac.uk';
- $dbname = 'c1626152';
- //Basket vars
- session_start();
- // Start basket empty
- $quantity = 0;
- $sql = "SELECT * FROM MyGuests";
- $result = $connector->query($sql);
- session_get_cookie_params();
- $id = $_COOKIE['customer'];
- foreach($result as $customerInfo):
- if ($_COOKIE['customer'] == $customerInfo['customer']){
- $_SESSION['basket'] = array('id'=>$customer['id'], 'quantity'=>$quantity);
- }
- function addItem()
- array_push($_SESSION['basket'] , $product['id']]);
- foreach($basket['id'])
- if $basket['id'] == $_REQUEST['id']{
- $basket['quantity']++;
- break;
- }
- function deleteItem()
- $delete == $_SESSION['basket'];
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement