This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
echo '<div id="bg">';
|
||||
|
||||
for ($i = 0; $i < 50; $i++)
|
||||
echo '<div id="' . $i . '" class="bubble"></div>';
|
||||
|
||||
echo '</div>';
|
||||
@@ -0,0 +1,101 @@
|
||||
<?php
|
||||
|
||||
function cart_checkout($total)
|
||||
{
|
||||
$checkout = '
|
||||
<div class="card full_width column padding shadow" style="height: auto;">
|
||||
<form method="post">
|
||||
<input type="hidden" name="form_id" value="checkout">
|
||||
<div class="row full_width space_between margin-top margin-bottom">
|
||||
<div class="column md_width">
|
||||
<label for="fname">First Name:</label>
|
||||
<input id="fname" name="fname" placeholder="John" required>
|
||||
</div>
|
||||
|
||||
<div class="column md_width">
|
||||
<label for="lname">Last Name:</label>
|
||||
<input id="lname" name="lname" placeholder="Smith" required>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="column full_width">
|
||||
<label for="add">Address:</label>
|
||||
<input id="add" name="add" placeholder="123 Example St" required>
|
||||
</div>
|
||||
|
||||
<div class="row space_between margin-top margin-bottom">
|
||||
<div class="column md_width">
|
||||
<label for="city">City:</label>
|
||||
<input id="city" name="city" placeholder="Salt Lake City" required>
|
||||
</div>
|
||||
<div class="column sm_width">
|
||||
<label for="state">State:</label>
|
||||
<select id="state" name="state" required>
|
||||
<option value="AL">AL</option>
|
||||
<option value="AK">AK</option>
|
||||
<option value="AZ">AZ</option>
|
||||
<option value="AR">AR</option>
|
||||
<option value="CA">CA</option>
|
||||
<option value="CO">CO</option>
|
||||
<option value="CT">CT</option>
|
||||
<option value="DE">DE</option>
|
||||
<option value="FL">FL</option>
|
||||
<option value="GA">GA</option>
|
||||
<option value="HI">HI</option>
|
||||
<option value="ID">ID</option>
|
||||
<option value="IL">IL</option>
|
||||
<option value="IN">IN</option>
|
||||
<option value="IA">IA</option>
|
||||
<option value="KS">KS</option>
|
||||
<option value="KY">KY</option>
|
||||
<option value="LA">LA</option>
|
||||
<option value="ME">ME</option>
|
||||
<option value="MD">MD</option>
|
||||
<option value="MA">MA</option>
|
||||
<option value="MI">MI</option>
|
||||
<option value="MN">MN</option>
|
||||
<option value="MS">MS</option>
|
||||
<option value="MO">MO</option>
|
||||
<option value="MT">MT</option>
|
||||
<option value="NE">NE</option>
|
||||
<option value="NV">NV</option>
|
||||
<option value="NH">NH</option>
|
||||
<option value="NJ">NJ</option>
|
||||
<option value="NM">NM</option>
|
||||
<option value="NY">NY</option>
|
||||
<option value="NC">NC</option>
|
||||
<option value="ND">ND</option>
|
||||
<option value="OH">OH</option>
|
||||
<option value="OK">OK</option>
|
||||
<option value="OR">OR</option>
|
||||
<option value="PA">PA</option>
|
||||
<option value="RI">RI</option>
|
||||
<option value="SC">SC</option>
|
||||
<option value="SD">SD</option>
|
||||
<option value="TN">TN</option>
|
||||
<option value="TX">TX</option>
|
||||
<option value="UT">UT</option>
|
||||
<option value="VT">VT</option>
|
||||
<option value="VA">VA</option>
|
||||
<option value="WA">WA</option>
|
||||
<option value="WV">WV</option>
|
||||
<option value="WI">WI</option>
|
||||
<option value="WY">WY</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="column sm_width">
|
||||
<label for="zip">Zip Code:</label>
|
||||
<input id="zip" name="zip" placeholder="84111" required>
|
||||
</div>
|
||||
</div>
|
||||
<div class="line margin-bottom"></div>
|
||||
<div class="column center">
|
||||
<h3 id="total">' . format_money($total) . '</h3>
|
||||
<input type="submit" value="Place Order">
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
';
|
||||
|
||||
return $checkout;
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
function cart_confirmation($fname, $lname, $add, $city, $state, $zip, $total, $items)
|
||||
{
|
||||
$con = '
|
||||
<div class="glass column md_width center padding" style="height: auto;">
|
||||
<h4>Shipping Details:</h4>
|
||||
<p>' . $fname . ' ' . $lname . '</p>
|
||||
<p>' . $add . '</p>
|
||||
<p>' . $city . ', ' . $state . ' ' . $zip . '</p>
|
||||
<br>
|
||||
<p>Your order will spontaneously appear before you, for you convenience!</p>
|
||||
<small>We fold space and time itself, to ensure the best experience for our customers!</small>
|
||||
<div class="line"></div>
|
||||
<h4>Your Items:</h4>
|
||||
<ul>
|
||||
';
|
||||
|
||||
foreach ($items as $name => $quantity)
|
||||
$con .= '<li>x' . $quantity . ' - ' . $name . '</li>';
|
||||
|
||||
$con .= '
|
||||
</ul>
|
||||
<h5>Total: $' . $total . '</h5>
|
||||
';
|
||||
|
||||
return $con;
|
||||
}
|
||||
@@ -1,19 +1,18 @@
|
||||
<?php
|
||||
|
||||
function cart_item($item)
|
||||
function cart_item($item, $q)
|
||||
{
|
||||
$item = '
|
||||
<div class="row">
|
||||
<div class="square img_container">
|
||||
<div class="row space_between full_width margin-bottom cart_item">
|
||||
<p class="full_width left_align">' . $item['name'] . '</p>
|
||||
<div class="row md_width right_align">
|
||||
<input type="hidden" value="' . $item['id'] . '">
|
||||
<input type="number" value="' . $q . '" class="full_width item_quantity">
|
||||
<div class="column center_children">
|
||||
<i class="nf nf-cod-trash"></i>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row space_between">
|
||||
<p>' . $item['description'] . '</p>
|
||||
<select>
|
||||
<input type="number">
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
';
|
||||
|
||||
return $item;
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
function cart_layout()
|
||||
{
|
||||
$total = 0;
|
||||
|
||||
$layout = '
|
||||
<div class="grid_2x1 center std_width glass padding">
|
||||
<div class="card list full_width padding shadow" style="height: 700px;">
|
||||
';
|
||||
|
||||
foreach ($_SESSION['cart'] as $id => $q) {
|
||||
$product = fetch_product($id);
|
||||
$total += $product['price'] * $q;
|
||||
$layout .= cart_item($product, $q);
|
||||
}
|
||||
|
||||
$layout .= '
|
||||
</div>
|
||||
' . cart_checkout($total) . '
|
||||
</div>
|
||||
';
|
||||
|
||||
return $layout;
|
||||
}
|
||||
+21
-14
@@ -2,20 +2,27 @@
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<link rel="stylesheet" href="css/base.css">
|
||||
<link rel="stylesheet" href="css/colors.css">
|
||||
<?php
|
||||
switch ($_SERVER['SCRIPT_NAME']) {
|
||||
case '/create-account.php':
|
||||
echo '<script src="js/create-account.js" defer></script>';
|
||||
break;
|
||||
case '/product.php':
|
||||
if (!isset($_SESSION['id']))
|
||||
echo '<script src="js/login-modal.js" defer></script>';
|
||||
break;
|
||||
}
|
||||
?>
|
||||
<link rel="stylesheet" href="css/base.css">
|
||||
<link rel="stylesheet" href="css/colors.css">
|
||||
<link rel="stylesheet" href="https://nerdfonts.com/assets/css/webfont.css">
|
||||
<script src="js/index.js" defer></script>
|
||||
<?php
|
||||
switch ($_SERVER['SCRIPT_NAME']) {
|
||||
case '/create-account.php':
|
||||
echo '<script src="js/create-account.js" defer></script>';
|
||||
break;
|
||||
case '/product.php':
|
||||
echo '<script src="js/product_page.js" defer></script>';
|
||||
break;
|
||||
case '/cart.php':
|
||||
echo '<script src="js/cart.js" defer></script>';
|
||||
break;
|
||||
}
|
||||
?>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<?php include_once 'nav.php'; ?>
|
||||
<?php
|
||||
include_once 'nav.php';
|
||||
include_once 'bubbles.php';
|
||||
?>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
$nav = '
|
||||
<nav>
|
||||
<nav class="glass">
|
||||
<ul>
|
||||
<div class="row space_between">
|
||||
<div>
|
||||
@@ -12,7 +12,19 @@ $nav = '
|
||||
</div>
|
||||
|
||||
<div>
|
||||
' . (isset($_SESSION['id']) ? '<li><a href="cart.php">Cart</a></li>' : '') . '
|
||||
';
|
||||
|
||||
if (isset($_SESSION['id'])) {
|
||||
$nav .= '
|
||||
<li>
|
||||
<a href="cart.php" id="cart">
|
||||
<i class="nf nf-md-cart"></i>
|
||||
' . (!empty($_SESSION['cart']) ? '<div id="dotton"><small>' . count($_SESSION['cart']) . '</small></div>' : '') . '
|
||||
</a>
|
||||
</li>';
|
||||
}
|
||||
|
||||
$nav .= '
|
||||
' . (isset($_SESSION['id']) ? '<li><a href="logout.php">Logout</a></li>' : '') . '
|
||||
' . (!isset($_SESSION['id']) ? '<li><a href="index.php">Login</a></li>' : '') . '
|
||||
' . (!isset($_SESSION['id']) ? '<li><a href="create-account.php">Signup</a></li>' : '') . '
|
||||
|
||||
@@ -2,18 +2,18 @@
|
||||
|
||||
function product_card($product)
|
||||
{
|
||||
$card = '
|
||||
<a class="card column center full_width padding" href="product.php?id=' . $product['id'] . '">
|
||||
$card = '
|
||||
<a class="card column center full_width padding shadow" href="product.php?id=' . $product['id'] . '">
|
||||
<div class="img_container">
|
||||
<img src="img/' . $product['image'] . '">
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<h4>' . $product['name'] . '</h4>
|
||||
<h5>' . $product['price'] . '</h5>
|
||||
<div class="column">
|
||||
<h5>' . $product['name'] . '</h5>
|
||||
<p>' . format_money($product['price']) . '</p>
|
||||
</div>
|
||||
</a>
|
||||
';
|
||||
|
||||
return $card;
|
||||
return $card;
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
function catalog_grid($products)
|
||||
{
|
||||
$grid = '
|
||||
<div class="grid center">
|
||||
<div class="grid center glass padding-top padding-bottom padding-left">
|
||||
';
|
||||
|
||||
foreach ($products as $p)
|
||||
|
||||
@@ -2,25 +2,26 @@
|
||||
function product_page($product)
|
||||
{
|
||||
$page = '
|
||||
<div class="product_page_card column center full_width padding">
|
||||
<div class="product_page_card glass column center full_width padding margin-top">
|
||||
<div class="img_container">
|
||||
<img src="img/' . $product['image'] . '">
|
||||
</div>
|
||||
<div class="column">
|
||||
<div class="column card full_width padding margin-top shadow" style="height: auto;">
|
||||
<div class="row space_between">
|
||||
<h3>' . $product['name'] . '</h3>
|
||||
<h3>' . $product['price'] . '</h3>
|
||||
<h3>' . format_money($product['price']) . '</h3>
|
||||
</div>
|
||||
|
||||
<p>' . $product['description'] . '</p>
|
||||
<form class="row" id="add_to_cart">
|
||||
<input type="hidden" name="is_logged_in" value="' . (isset($_SESSION['id']) ? 'true' : 'false') . '">
|
||||
<div class="column margin">
|
||||
<form class="row space_between" id="add_to_cart">
|
||||
<input type="hidden" name="is_logged_in" value="' . (isset($_SESSION['id']) ? 'true' : 'false') . '" id="is_logged_in">
|
||||
<input type="hidden" name="product_id" value="' . $product['id'] . '" id="product_id">
|
||||
<div class="column margin center_children">
|
||||
<label for="quantity">Quantity:</label>
|
||||
<input type="number" value="1" id="quantity" name="quantity" min="1">
|
||||
<input type="number" value="1" id="quantity" name="quantity" min="1" class="md_width">
|
||||
</div>
|
||||
|
||||
<input type="submit" value="Add to Cart" class="margin">
|
||||
<input type="submit" class="margin" id="add_to_cart_btn" value="Add to Cart">
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -2,23 +2,26 @@
|
||||
function login_form()
|
||||
{
|
||||
$form = '
|
||||
<div class="card center">
|
||||
<form method="post" id="login_form">
|
||||
<div class="glass center center_children padding md_width">
|
||||
<form method="post" id="login_form" class="card full_width padding" style="height: auto;">
|
||||
<div class="column center">
|
||||
<div class="column">
|
||||
<div class="column margin-bottom">
|
||||
<label for="username">Username:</label>
|
||||
<input id="username" name="username" autofocus required>
|
||||
</div>
|
||||
|
||||
<div class="column">
|
||||
<div class="column margin-bottom">
|
||||
<label for="password">Password:</label>
|
||||
<input id="password" type="password" name="password" required>
|
||||
</div>
|
||||
|
||||
<a href="create-account.php">Signup Instead</a>
|
||||
<a href="create-account.php" class="margin-bottom">Signup Instead</a>
|
||||
|
||||
<input type="submit" class="button submit" id="login_submit">
|
||||
</div>
|
||||
<div class="column center error">
|
||||
<p id="invalid"></p>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
';
|
||||
|
||||
@@ -2,27 +2,27 @@
|
||||
function signup_form()
|
||||
{
|
||||
$form = '
|
||||
<div class="card center">
|
||||
<form method="post" class="column center">
|
||||
<div class="column">
|
||||
<div class="glass center md_width padding">
|
||||
<form method="post" class="card column center full_width padding" style="height: auto;">
|
||||
<div class="column margin-bottom">
|
||||
<label for="username">Username:</label>
|
||||
<input id="username" name="username" autofocus required>
|
||||
</div>
|
||||
|
||||
<div class="column">
|
||||
<div class="column margin-bottom">
|
||||
<label for="password">Password:</label>
|
||||
<input id="password" type="password" name="password" required>
|
||||
</div>
|
||||
|
||||
<div class="column">
|
||||
<div class="column margin-bottom">
|
||||
<label for="v_password">Verify Password:</label>
|
||||
<input id="v_password" type="password" name="v_password" required>
|
||||
</div>
|
||||
|
||||
<a href="index.php">Login Instead</a>
|
||||
<a href="index.php" class="margin-bottom">Login Instead</a>
|
||||
|
||||
<div class="row full_width">
|
||||
<input type="submit" class="button submit">
|
||||
<div class="row space_between full_width">
|
||||
<input type="submit" class="button submit" value="Create">
|
||||
<input type="reset" class="button">
|
||||
</div>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user