diff --git a/account_statement.php b/account_statement.php deleted file mode 100644 index e3df0aa..0000000 --- a/account_statement.php +++ /dev/null @@ -1,118 +0,0 @@ -prepare("SELECT * FROM orders WHERE user_id = ? ORDER BY order_date DESC"); -$stmt->execute([$user_id]); -$orders = $stmt->fetchAll(); -?> - - - - - - Account Statement - - - - - - - -
-
-
-

Account Statement

-
-
-
Your Order History
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Order IDOrder DateFuel TypeQuantity (Litres)Total PriceStatus
You have no orders yet.
$ - -
-
-
-
-
- - - - diff --git a/admin.php b/admin.php deleted file mode 100644 index 9c7e319..0000000 --- a/admin.php +++ /dev/null @@ -1,222 +0,0 @@ -prepare("UPDATE prices SET price = :price WHERE fuel_type = :fuel_type"); - $stmt->execute(['price' => $petrol_price, 'fuel_type' => 'petrol']); - $stmt->execute(['price' => $diesel_price, 'fuel_type' => 'diesel']); - $success = 'Prices updated successfully!'; - } catch (PDOException $e) { - $error = 'Database error: ' . $e->getMessage(); - } -} - -// Fetch current prices and orders if admin is logged in -$prices = []; -$orders = []; -if (isset($_SESSION['admin_logged_in']) && $_SESSION['admin_logged_in']) { - require_once 'db/config.php'; - try { - $pdo = db(); - // Fetch prices - $stmt = $pdo->query("SELECT * FROM prices"); - $all_prices = $stmt->fetchAll(); - foreach ($all_prices as $p) { - $prices[$p['fuel_type']] = $p['price']; - } - // Fetch orders - $stmt = $pdo->query("SELECT * FROM orders ORDER BY order_date DESC"); - $orders = $stmt->fetchAll(); - - } catch (PDOException $e) { - $error = 'Database error: ' . $e->getMessage(); - } -} - -// Check for status update messages -if (isset($_SESSION['update_success'])) { - $success = $_SESSION['update_success']; - unset($_SESSION['update_success']); -} -if (isset($_SESSION['update_error'])) { - $error = $_SESSION['update_error']; - unset($_SESSION['update_error']); -} - - -?> - - - - - - Admin - Petrol Price Management - - - - - - - -
-
-
- -
-
-

Admin Login

-
-
- -
- -
- -
- - -
-
- - -
-
- -
-
-
-
- -
-
-

Update Fuel Prices

-
-
-
-
-
- -
- - -
-
- - -
-
- -
-
-
-
- -
-
-

Order Management

-
-
-
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Order IDCustomerFuel TypeQuantity (L)Total PriceOrder DateStatusAction
No orders found.
$
- - - - -
-
-
-
- -
-
-
- - - - \ No newline at end of file diff --git a/assets/css/custom.css b/assets/css/custom.css deleted file mode 100644 index f7cd582..0000000 --- a/assets/css/custom.css +++ /dev/null @@ -1,46 +0,0 @@ -:root { - --brand-orange: #fd7e14; - --brand-navy-blue: #0a2351; - --brand-light-gray: #f8f9fa; - --brand-dark-gray: #212529; - --brand-white: #ffffff; -} - -body { - font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; -} - -.bg-dark-blue { - background-color: var(--brand-navy-blue); -} - -.btn-brand-orange { - background-color: var(--brand-orange); - color: var(--brand-white); - border: none; -} - -.btn-brand-orange:hover { - background-color: #e66a00; - color: var(--brand-white); -} - -.hero-section { - background-color: var(--brand-navy-blue); - padding: 100px 0; - background-size: cover; - background-position: center; - min-height: 400px; - display: flex; - align-items: center; - justify-content: center; -} - -.navbar-brand { - font-weight: bold; -} - -#contact form .form-control:focus { - border-color: var(--brand-orange); - box-shadow: 0 0 0 0.25rem rgba(253, 126, 20, 0.25); -} \ No newline at end of file diff --git a/assets/js/main.js b/assets/js/main.js deleted file mode 100644 index 8b87476..0000000 --- a/assets/js/main.js +++ /dev/null @@ -1,38 +0,0 @@ -document.addEventListener('DOMContentLoaded', function () { - const urlParams = new URLSearchParams(window.location.search); - const status = urlParams.get('status'); - - if (status) { - let message = ''; - let type = 'success'; - - if (status === 'success') { - message = 'Thank you for your message! We will get back to you shortly.'; - } else if (status === 'error') { - message = 'Something went wrong. Please try again.'; - type = 'danger'; - } - - if (message) { - const toastContainer = document.getElementById('toast-container'); - const toastHTML = ` - - `; - toastContainer.innerHTML = toastHTML; - - const toastElement = toastContainer.querySelector('.toast'); - const toast = new bootstrap.Toast(toastElement, { delay: 5000 }); - toast.show(); - } - - // Clean the URL - window.history.replaceState({}, document.title, window.location.pathname); - } -}); diff --git a/contact_handler.php b/contact_handler.php deleted file mode 100644 index fad0e6f..0000000 --- a/contact_handler.php +++ /dev/null @@ -1,36 +0,0 @@ - 'danger', 'message' => 'Invalid input. Please fill out all fields correctly.']; - header("Location: index.php#contact"); - exit; - } - - // The email will be sent to the address configured in .env (MAIL_TO) - // The user's email is used as the Reply-To address. - $subject = 'New Account Request from ' . $name; - - $res = MailService::sendContactMessage($name, $email, $message, null, $subject); - - if (!empty($res['success'])) { - $_SESSION['status'] = ['type' => 'success', 'message' => 'Thank you for your request! We will get back to you shortly.']; - } else { - // Avoid showing detailed errors to the user. - // error_log('MailService Error: ' . ($res['error'] ?? 'Unknown error')); - $_SESSION['status'] = ['type' => 'danger', 'message' => 'Sorry, there was an error sending your message. Please try again later.']; - } - -} else { - $_SESSION['status'] = ['type' => 'danger', 'message' => 'Invalid request method.']; -} - -header("Location: index.php#contact"); -exit; \ No newline at end of file diff --git a/dashboard.php b/dashboard.php deleted file mode 100644 index 32cbdca..0000000 --- a/dashboard.php +++ /dev/null @@ -1,233 +0,0 @@ -query("SELECT * FROM prices ORDER BY updated_at DESC LIMIT 1"); - $latest_prices = $stmt->fetch(); - if ($latest_prices) { - $petrol_price = $latest_prices['petrol_price']; - $diesel_price = $latest_prices['diesel_price']; - } -} catch (PDOException $e) { - error_log("Could not fetch prices: " . $e->getMessage()); -} - -// Fetch user's orders -$orders = []; -try { - $stmt = $pdoconn->prepare("SELECT * FROM orders WHERE user_id = :user_id ORDER BY order_date DESC"); - $stmt->execute([':user_id' => $user['id']]); - $orders = $stmt->fetchAll(); -} catch (PDOException $e) { - error_log("Could not fetch orders: " . $e->getMessage()); -} - -require_once 'includes/pexels.php'; -$bg_image_data = pexels_get('https://api.pexels.com/v1/search?query=abstract+background&orientation=landscape&per_page=1&page=1'); -$bg_image = ''; // Default empty -if ($bg_image_data && !empty($bg_image_data['photos'])) { - $photo = $bg_image_data['photos'][0]; - $src = $photo['src']['large2x'] ?? ($photo['src']['large'] ?? $photo['src']['original']); - $target = __DIR__ . '/assets/images/pexels/' . $photo['id'] . '.jpg'; - download_to($src, $target); - $bg_image = 'assets/images/pexels/' . $photo['id'] . '.jpg'; -} - -?> - - - - - - Customer Dashboard - - - - - - - -
- - -
-
- Welcome, ! -
-
- - - - - - - - - -

Dashboard

-

Welcome to your customer portal. Here you can view prices, place orders, and see your account history.

- -
-
-
-
Today's Prices
-
-

Petrol: $ / litre

-

Diesel: $ / litre

- Prices are updated daily. -
-
-
-
-
-
Banking Details
-
-

Please use the following details for payments:

-
    -
  • Bank A: 123-456-7890
  • -
  • Bank B: 098-765-4321
  • -
-
-
-
-
- -
-
-
-
Place a New Order
-
-
-
- - -
-
- - -
- -
-
-
-
-
- - - -
-
-
- - - - \ No newline at end of file diff --git a/db/config.php b/db/config.php index 1edff8c..bb98f7d 100644 --- a/db/config.php +++ b/db/config.php @@ -8,29 +8,10 @@ define('DB_PASS', 'e45f2778-db1f-450c-99c6-29efb4601472'); function db() { static $pdo; if (!$pdo) { - try { - $pdo = new PDO('mysql:host='.DB_HOST.';dbname='.DB_NAME.';charset=utf8mb4', DB_USER, DB_PASS, [ - PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, - PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC, - ]); - } catch (PDOException $e) { - // If the database doesn't exist, create it. - if ($e->getCode() === 1049) { // SQLSTATE[HY000] [1049] Unknown database - try { - $tempPdo = new PDO('mysql:host='.DB_HOST, DB_USER, DB_PASS); - $tempPdo->exec('CREATE DATABASE IF NOT EXISTS `'. DB_NAME . '`'); - // Now, reconnect with the database name. - $pdo = new PDO('mysql:host='.DB_HOST.';dbname='.DB_NAME.';charset=utf8mb4', DB_USER, DB_PASS, [ - PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, - PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC, - ]); - } catch (PDOException $creationException) { - die("DB ERROR: Failed to create database. " . $creationException->getMessage()); - } - } else { - die("DB ERROR: " . $e->getMessage()); - } - } + $pdo = new PDO('mysql:host='.DB_HOST.';dbname='.DB_NAME.';charset=utf8mb4', DB_USER, DB_PASS, [ + PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, + PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC, + ]); } return $pdo; } diff --git a/index.php b/index.php index 55eba60..7205f3d 100644 --- a/index.php +++ b/index.php @@ -1,164 +1,150 @@ - + + - - - Fuel Distribution Co. - - + + + New Style + + + + + + + + + + + + + + + + + + + - - - - - - - - -
-
-

Reliable Fuel Distribution

-

Your trusted partner for timely petrol and diesel supply.

-
-
- -
-
-
-
-

About Us

-

We are a leading fuel distribution company dedicated to providing businesses with high-quality petrol and diesel. Our commitment to efficiency and customer service ensures your operations never run dry. We offer customized pricing and delivery schedules to meet your specific needs.

-
-
- About Us Image -
-
-
-
- - -
-
-
-

Our Services

-

We deliver petrol and diesel directly to your business.

-
-
-
-
-
-
Petrol Delivery
-

High-octane petrol for your fleet and machinery, delivered on schedule.

-
-
-
-
-
-
-
Diesel Delivery
-

Bulk diesel for commercial vehicles, generators, and industrial equipment.

-
-
-
-
-
-
- -
-
-
-

Contact Us

-

Interested in opening an account? Fill out the form below.

-
- - - - - - -
-
-
-
- - -
-
- - -
-
- - -
-
- -
-
-
-
-
-
- - - - +
+
+

Analyzing your requirements and generating your website…

+
+ Loading… +
+

AI is collecting your requirements and applying the first changes.

+

This page will update automatically as the plan is implemented.

+

Runtime: PHP — UTC

+
+
+ - \ No newline at end of file + diff --git a/login.php b/login.php deleted file mode 100644 index 63ab76a..0000000 --- a/login.php +++ /dev/null @@ -1,75 +0,0 @@ - - - - - - - Login - Petrol Price Management - - - - - - -
-
-
- -
-
-
- - - - diff --git a/login_handler.php b/login_handler.php deleted file mode 100644 index 26d8062..0000000 --- a/login_handler.php +++ /dev/null @@ -1,37 +0,0 @@ - [ - 'password' => 'password', - 'name' => 'Test Customer', - 'company' => 'Example Inc.' - ] -]; - -if ($_SERVER['REQUEST_METHOD'] === 'POST') { - $email = $_POST['email'] ?? ''; - $password = $_POST['password'] ?? ''; - - if (isset($users[$email]) && $users[$email]['password'] === $password) { - // Login successful - $_SESSION['user'] = [ - 'email' => $email, - 'name' => $users[$email]['name'], - 'company' => $users[$email]['company'] - ]; - header('Location: dashboard.php'); - exit; - } else { - // Login failed - $_SESSION['error'] = 'Invalid email or password.'; - header('Location: login.php'); - exit; - } -} else { - // Redirect if accessed directly - header('Location: login.php'); - exit; -} diff --git a/logout.php b/logout.php deleted file mode 100644 index e58edd6..0000000 --- a/logout.php +++ /dev/null @@ -1,22 +0,0 @@ -query("SELECT * FROM prices ORDER BY updated_at DESC LIMIT 1"); - $latest_prices = $stmt->fetch(); - - if (!$latest_prices) { - $_SESSION['order_error'] = "Could not retrieve latest prices. Please try again later."; - header('Location: dashboard.php'); - exit; - } - - $price = ($fuel_type === 'petrol') ? $latest_prices['petrol_price'] : $latest_prices['diesel_price']; - $total_price = $quantity * $price; - - // Insert the order - $sql = "INSERT INTO orders (user_id, fuel_type, quantity, total_price) VALUES (:user_id, :fuel_type, :quantity, :total_price)"; - $stmt = $pdoconn->prepare($sql); - $stmt->execute([ - ':user_id' => $user_id, - ':fuel_type' => $fuel_type, - ':quantity' => $quantity, - ':total_price' => $total_price - ]); - - $_SESSION['order_success'] = "Your order has been placed successfully!"; - header('Location: dashboard.php'); - exit; - - } catch (PDOException $e) { - error_log("Order submission failed: " . $e->getMessage()); - $_SESSION['order_error'] = "There was an error placing your order. Please try again."; - header('Location: dashboard.php'); - exit; - } -} else { - // Redirect if accessed directly - header('Location: dashboard.php'); - exit; -} -?> \ No newline at end of file diff --git a/profile.php b/profile.php deleted file mode 100644 index aca0472..0000000 --- a/profile.php +++ /dev/null @@ -1,77 +0,0 @@ -prepare($sql)) { - $stmt->bindParam(":id", $user_id, PDO::PARAM_INT); - if ($stmt->execute()) { - if ($stmt->rowCount() == 1) { - if ($row = $stmt->fetch()) { - $name = $row["name"]; - $email = $row["email"]; - } - } - } - unset($stmt); -} -unset($pdo); - -// Include header -include 'includes/header.php'; -?> - -
-

User Profile

-

Edit your personal information.

- - ' . $_SESSION['success_message'] . '
'; - unset($_SESSION['success_message']); - } - if (!empty($_SESSION['error_message'])) { - echo '
' . $_SESSION['error_message'] . '
'; - unset($_SESSION['error_message']); - } - ?> - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- -
-
- - - diff --git a/update_order_status.php b/update_order_status.php deleted file mode 100644 index 169b557..0000000 --- a/update_order_status.php +++ /dev/null @@ -1,42 +0,0 @@ -prepare("UPDATE orders SET status = :status WHERE id = :order_id"); - $stmt->execute(['status' => $status, 'order_id' => $order_id]); - - if ($stmt->rowCount()) { - $_SESSION['update_success'] = "Order #{$order_id} has been updated to '{$status}'."; - } else { - $_SESSION['update_error'] = "Could not find Order #{$order_id} to update."; - } - } catch (PDOException $e) { - $_SESSION['update_error'] = 'Database error: ' . $e->getMessage(); - } -} else { - $_SESSION['update_error'] = 'Invalid request.'; -} - -header('Location: admin.php'); -exit; diff --git a/update_profile.php b/update_profile.php deleted file mode 100644 index 591623a..0000000 --- a/update_profile.php +++ /dev/null @@ -1,60 +0,0 @@ -prepare($sql)) { - $stmt->bindParam(":name", $name, PDO::PARAM_STR); - $stmt->bindParam(":email", $email, PDO::PARAM_STR); - $stmt->bindParam(":id", $user_id, PDO::PARAM_INT); - - if (!empty($new_password)) { - $stmt->bindParam(":password", $hashed_password, PDO::PARAM_STR); - } - - if ($stmt->execute()) { - $_SESSION['success_message'] = "Your profile has been updated successfully."; - } else { - $_SESSION['error_message'] = "Oops! Something went wrong. Please try again later."; - } - unset($stmt); - } - unset($pdo); - - header("location: profile.php"); - exit; -} -?> \ No newline at end of file