Commit eb764415 authored by BaconLover307's avatar BaconLover307
Browse files

update readme:

parent d23c6c6a
......@@ -18,6 +18,18 @@ Website Willy Wangky adalah website berbasis php yang digunakan untuk membeli co
1. install [XAMPP](https://www.apachefriends.org/index.html)
2. masukkan path directory `php.exe` pada instalasi XAMPP `...xampp\php` (biasanya terdapat di `C:\xampp\php`) ke dalam PATH environment variables.
3. Buat db_keys.config.php pada folder config berisi
```
<?php
define('DB_SERVER', 'localhost');
define('DB_USERNAME', 'root');
define('DB_PASSWORD', 'root'); // Default password mysql xampp itu kosong, tiati bentrok ama mysql server yg udah ada
define('DB_NAME', 'wbd1'); // Buat dulu databasenya yak baru ntar pergi ke localhost:xxxx/config/init_db.php
?>
```
4. Jalankan init_db.php pada folder config untuk generate database
## How to Run
......@@ -26,16 +38,20 @@ Website Willy Wangky adalah website berbasis php yang digunakan untuk membeli co
1. Jalankan XAMPP
2. Start Apache dan MySQL Module pada XAMPP
3. Di direktori tempat repository berada, jalankan:
```
php -S localhost:8000
```
Sebagai contoh digunakan port 8000.
Sebagai contoh digunakan port 8000.
4. Jalankan browser dan pergi ke link `localhost:8000` .
Sebagai contoh jika ingin pergi ke dashboard, pada project kami dapat dilakukan navigasi ke `localhost:8000/src/dasboard.php`
## Screenshot dari Tugas
-------
---
1. Login ![login](./docs/img/login.PNG)
2. Register ![register](./docs/img/register.PNG)
3. Dashboard ![dashboard](./docs/img/dashboard.PNG)
......@@ -68,8 +84,8 @@ Website Willy Wangky adalah website berbasis php yang digunakan untuk membeli co
2. Register: 13518146
3. Dashboard: 13518135
4. Chocolate Detail: 13518125
5. Buy Chocolate: 13518135
6. Add Chocolate: 13518135
5. Buy Chocolate: 13518125, 13518135, 13518146
6. Add Chocolate: 13518125, 13518135, 13518146
7. Search Results: 13518125
8. Transaction History: 13518135, 13518146
9. New Chocolate: 13518146
......
<?php
['validate_token' => $validate_token] = require 'utils/authentication.php';
['make_token' => $make_token] = require 'utils/authentication.php';
['connect_db' => $connect_db] = require 'utils/db_connect.php';
if (!isset($_COOKIE['sessionID'])) {
header("location: login.php");
......@@ -37,6 +38,30 @@ if (isset($_GET['id'])) {
extract($chocolate);
}
if ($_SERVER["REQUEST_METHOD"] === "POST") {
$quantity = $_POST["quantity"];
$id = $_POST["id"];
$amount = $_POST["amount"];
$total = $amount + $quantity;
try {
$sql = "UPDATE chocolates SET amount = :total WHERE id = :id";
$pdo = $connect_db();
$stmt = $pdo->prepare($sql);
$stmt->bindParam(":total", $total);
$stmt->bindParam(":id", $id);
$stmt->execute();
$id = $pdo->lastInsertId();
header("location: dashboard.php");
exit;
} catch (Exception $error) {
$error_message = $error->getMessage();
}
}
?>
......@@ -70,41 +95,23 @@ if (isset($_GET['id'])) {
<div class="choco-desc" id="choco-desc"><?php echo $description ?></div>
</div>
<div style="display: none" id='ori-price'>
<?php echo $price ?></div>
<div>
<form id="buyChocolate" action="buy_chocolate.php" method="POST" class="amount-modifier text-content">
<?php
if ($amount === 0) {
echo "<div> Items is currently sold out.. </div>";
} else {
echo '
<div>
<div>Amount to add:</div>
<div class="mod text-subtitle">
<button type="button" id="minus"> - </button>
<input class="mod-number text-subtitle" type="number" id="quantity" name="quantity" min="1" max="100000">
<button type="button" id="plus"> + </button>
</div>
</div>
';
}
?>
<!-- <div class="total-container">
<div>Total Price</div>
<div class="total-display text-title">Rp <a id="total-price"><a>,00</div>
</div> -->
</form>
</div>
<div>
</div>
<!-- price_block -->
</div>
</div>
<form class="form-bawah" id="buyChocolate" action="buy_chocolate.php" method="POST">
<form class="form-bawah text-subtitle " id="addChocolate" action="add_chocolate.php" method="POST">
<div>
<input type="number" style="display: none" id='id' name='id' value="<?php echo $id ?>">
<input type="number" style="display: none" id='amount' name='amount' value="<?php echo $amount ?>">
<div>Amount to add:</div>
<div class="mod text-subtitle">
<button type="button" id="minus"> - </button>
<input class="mod-number text-subtitle" type="number" id="quantity" name="quantity" min="1" max="100000">
<button type="button" id="plus"> + </button>
</div>
</div>
<div class="btn-group ">
<button class="btn-secondary text-subtitle"> Cancel </button>
<button class="btn-primary text-subtitle" id="btn-buy">Buy</button>
<button class="btn-primary text-subtitle" id="btn-buy">Add</button>
</div>
</form>
</div>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment