v1.incomplete

This commit is contained in:
Flatlogic Bot 2025-12-05 19:48:45 +00:00
parent b53a7ac947
commit 1b66a017fa
14 changed files with 879 additions and 149 deletions

166
assets/css/custom.css Normal file
View File

@ -0,0 +1,166 @@
/* General Body Styles */
body {
font-family: 'Roboto', sans-serif;
color: #333;
line-height: 1.6;
}
/* Typography */
h1, h2, h3, h4, h5, h6 {
font-family: 'Poppins', sans-serif;
font-weight: 700;
}
/* Header & Navbar */
.navbar {
transition: background-color 0.3s ease-in-out;
}
.navbar-brand {
font-family: 'Poppins', sans-serif;
font-weight: 700;
color: #fff !important;
}
.nav-link {
font-weight: 500;
transition: color 0.2s;
}
/* Hero Section */
.hero-section {
background: linear-gradient(135deg, #007BFF, #0056b3);
color: white;
padding: 100px 0;
text-align: center;
}
.hero-section h1 {
font-size: 3.5rem;
font-weight: 700;
margin-bottom: 0.5rem;
}
.hero-section .lead {
font-size: 1.25rem;
margin-bottom: 2rem;
}
.btn-primary {
background-color: #fff;
border-color: #fff;
color: #007BFF;
font-weight: 700;
padding: 0.75rem 1.5rem;
border-radius: 50px;
transition: all 0.3s ease;
}
.btn-primary:hover {
background-color: #f0f0f0;
border-color: #f0f0f0;
transform: translateY(-2px);
}
/* Sections */
.section {
padding: 80px 0;
}
.section-title {
text-align: center;
margin-bottom: 4rem;
font-size: 2.5rem;
font-weight: 700;
}
/* Segment Cards */
.segment-card {
border: none;
border-radius: 0.75rem;
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
transition: transform 0.3s, box-shadow 0.3s;
overflow: hidden;
}
.segment-card:hover {
transform: translateY(-10px);
box-shadow: 0 15px 40px rgba(0, 0, 0, 0.12);
}
.segment-card .card-body {
padding: 2rem;
}
/* Pricing/Plans Section */
.pricing-card {
border-radius: 0.75rem;
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
transition: transform 0.3s, box-shadow 0.3s;
border: none;
}
.pricing-card:hover {
transform: translateY(-10px);
box-shadow: 0 15px 40px rgba(0, 0, 0, 0.12);
}
.pricing-card .card-header {
background: transparent;
border-bottom: none;
padding: 1.5rem;
}
.pricing-card .price {
font-size: 2.5rem;
font-weight: 700;
}
.pricing-card .price .period {
font-size: 1rem;
font-weight: 400;
color: #6c757d;
}
.pricing-card .btn {
border-radius: 50px;
font-weight: 700;
padding: 0.75rem 1.5rem;
}
.pricing-card.featured {
border: 2px solid #007BFF;
}
.pricing-card.featured .btn-primary {
background-color: #007BFF;
border-color: #007BFF;
color: #fff;
}
.pricing-card.featured .btn-primary:hover {
background-color: #0056b3;
border-color: #0056b3;
}
/* Footer */
.footer {
background-color: #343a40;
color: #f8f9fa;
padding: 40px 0;
}
.footer a {
color: #f8f9fa;
text-decoration: none;
transition: color 0.2s;
}
.footer a:hover {
color: #007BFF;
}
.social-icons a {
font-size: 1.5rem;
margin: 0 0.5rem;
}

37
assets/js/main.js Normal file
View File

@ -0,0 +1,37 @@
document.addEventListener('DOMContentLoaded', function () {
// Navbar transparency scroll effect
const navbar = document.querySelector('.navbar');
if (navbar) {
function handleScroll() {
if (window.scrollY > 50) {
navbar.classList.add('bg-dark');
} else {
navbar.classList.remove('bg-dark');
}
}
// Initial check
handleScroll();
// Listen for scroll events
window.addEventListener('scroll', handleScroll);
}
// Smooth scrolling for anchor links
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', function (e) {
e.preventDefault();
const targetId = this.getAttribute('href');
const targetElement = document.querySelector(targetId);
if (targetElement) {
targetElement.scrollIntoView({
behavior: 'smooth'
});
}
});
});
});

75
dashboard.php Normal file
View File

@ -0,0 +1,75 @@
<?php
if (!isset($_SESSION['user_id'])) {
header('Location: login.php');
exit;
}
require_once 'includes/header.php';
?>
<div class="container mt-5">
<div class="row">
<div class="col-md-12">
<h1>Welcome to your Dashboard, <?php echo htmlspecialchars($_SESSION['user_name']); ?>!</h1>
<p>This is your central hub to manage your account and services. More features will be added soon.</p>
</div>
</div>
<div class="row mt-5">
<div class="col-md-12">
<h2>Your Subscribed Services</h2>
<?php
require_once 'db/config.php';
$pdo = db();
$stmt = $pdo->prepare("SELECT s.name, s.description FROM services s JOIN user_services us ON s.id = us.service_id WHERE us.user_id = ? AND us.status = 'active'");
$stmt->execute([$_SESSION['user_id']]);
$user_services = $stmt->fetchAll(PDO::FETCH_ASSOC);
if (count($user_services) > 0) {
echo "<ul class='list-group'>";
foreach ($user_services as $service) {
echo "<li class='list-group-item'>";
echo "<strong>" . htmlspecialchars($service['name']) . "</strong>: " . htmlspecialchars($service['description']);
echo "</li>";
}
echo "</ul>";
} else {
echo "<p>You are not subscribed to any services yet.</p>";
}
?>
</div>
</div>
<div class="row mt-5">
<div class="col-md-12">
<h2>Available Services</h2>
</div>
</div>
<div class="row">
<?php
require_once 'db/config.php';
$pdo = db();
$stmt = $pdo->query("SELECT * FROM services");
$services = $stmt->fetchAll(PDO::FETCH_ASSOC);
foreach ($services as $service) {
?>
<div class="col-md-4 mb-4">
<div class="card">
<div class="card-body">
<h5 class="card-title"><?php echo htmlspecialchars($service['name']); ?></h5>
<p class="card-text"><?php echo htmlspecialchars($service['description']); ?></p>
<p class="card-text"><strong>$<?php echo htmlspecialchars($service['price']); ?></strong> / <?php echo htmlspecialchars($service['billing_cycle']); ?></p>
<a href="subscribe.php?service_id=<?php echo $service['id']; ?>" class="btn btn-primary">Subscribe</a>
</div>
</div>
</div>
<?php
}
?>
</div>
</div>
<?php require_once 'includes/footer.php'; ?>

View File

@ -0,0 +1,27 @@
<?php
require_once __DIR__ . '/../config.php';
function migrate_001_create_users_table() {
$pdo = db();
try {
$sql = '
CREATE TABLE IF NOT EXISTS users (
id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(255) NOT NULL,
email VARCHAR(255) NOT NULL UNIQUE,
password_hash VARCHAR(255) NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
';
$pdo->exec($sql);
echo "Migration 001: Users table created successfully." . PHP_EOL;
} catch (PDOException $e) {
die("Migration 001 failed: " . $e->getMessage() . PHP_EOL);
}
}
// Self-invocation check
if (basename(__FILE__) == basename($_SERVER["SCRIPT_FILENAME"])) {
migrate_001_create_users_table();
}

View File

@ -0,0 +1,20 @@
<?php
require_once __DIR__ . '/../../db/config.php';
try {
$pdo = db();
$sql = "
CREATE TABLE IF NOT EXISTS services (
id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(255) NOT NULL,
description TEXT,
price DECIMAL(10, 2) NOT NULL,
billing_cycle ENUM('monthly', 'yearly') NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
";
$pdo->exec($sql);
echo "Table 'services' created successfully." . PHP_EOL;
} catch (PDOException $e) {
die("Could not create table 'services': " . $e->getMessage());
}

View File

@ -0,0 +1,23 @@
<?php
require_once __DIR__ . '/../../db/config.php';
try {
$pdo = db();
$sql = "
CREATE TABLE IF NOT EXISTS user_services (
id INT AUTO_INCREMENT PRIMARY KEY,
user_id INT NOT NULL,
service_id INT NOT NULL,
status ENUM('active', 'cancelled', 'expired') NOT NULL DEFAULT 'active',
start_date TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
end_date TIMESTAMP NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE,
FOREIGN KEY (service_id) REFERENCES services(id) ON DELETE CASCADE
);
";
$pdo->exec($sql);
echo "Table 'user_services' created successfully." . PHP_EOL;
} catch (PDOException $e) {
die("Could not create table 'user_services': " . $e->getMessage());
}

View File

@ -0,0 +1,45 @@
<?php
require_once __DIR__ . '/../../db/config.php';
try {
$pdo = db();
$services = [
[
'name' => 'Basic Plan',
'description' => 'Access to basic features.',
'price' => 9.99,
'billing_cycle' => 'monthly'
],
[
'name' => 'Pro Plan',
'description' => 'Access to all features and priority support.',
'price' => 29.99,
'billing_cycle' => 'monthly'
],
[
'name' => 'Annual Basic Plan',
'description' => 'One year of the Basic Plan.',
'price' => 99.99,
'billing_cycle' => 'yearly'
],
[
'name' => 'Annual Pro Plan',
'description' => 'One year of the Pro Plan.',
'price' => 299.99,
'billing_cycle' => 'yearly'
]
];
$sql = "INSERT INTO services (name, description, price, billing_cycle) VALUES (:name, :description, :price, :billing_cycle)";
$stmt = $pdo->prepare($sql);
foreach ($services as $service) {
$stmt->execute($service);
}
echo "Services seeded successfully." . PHP_EOL;
} catch (PDOException $e) {
die("Could not seed services: " . $e->getMessage());
}

27
includes/footer.php Normal file
View File

@ -0,0 +1,27 @@
</main>
<!-- Footer -->
<footer class="footer">
<div class="container text-center">
<div class="social-icons mb-3">
<a href="#"><i class="bi bi-twitter-x"></i></a>
<a href="#"><i class="bi bi-facebook"></i></a>
<a href="#"><i class="bi bi-linkedin"></i></a>
</div>
<p>&copy; <?php echo date("Y"); ?> <?php echo htmlspecialchars($project_name); ?>. All Rights Reserved.</p>
<p>
<a href="#">About</a> &middot;
<a href="#">Contact</a> &middot;
<a href="#">Privacy Policy</a>
</p>
</div>
</footer>
<!-- Bootstrap JS Bundle -->
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
<!-- Custom JS -->
<script src="assets/js/main.js?v=<?php echo time(); ?>"></script>
</body>
</html>

91
includes/header.php Normal file
View File

@ -0,0 +1,91 @@
<?php session_start(); ?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- Bootstrap CSS -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
<!-- Bootstrap Icons -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css">
<!-- Google Fonts -->
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@400;700&family=Roboto:wght@400;500&display=swap" rel="stylesheet">
<!-- Custom CSS -->
<link rel="stylesheet" href="assets/css/custom.css?v=<?php echo time(); ?>">
<?php
$project_name = getenv("PROJECT_NAME") ?: "Telecommunications Platform";
$project_description = getenv("PROJECT_DESCRIPTION") ?: "A robust platform for all your telecommunication needs.";
$project_image_url = getenv("PROJECT_IMAGE_URL") ?: "assets/images/pexels-photo-267350.jpeg";
?>
<title><?php echo htmlspecialchars($project_name); ?></title>
<meta name="description" content="<?php echo htmlspecialchars($project_description); ?>">
<!-- Open Graph / Facebook -->
<meta property="og:type" content="website">
<meta property="og:title" content="<?php echo htmlspecialchars($project_name); ?>">
<meta property="og:description" content="<?php echo htmlspecialchars($project_description); ?>">
<meta property="og:image" content="<?php echo htmlspecialchars($project_image_url); ?>">
<!-- Twitter -->
<meta property="twitter:card" content="summary_large_image">
<meta property="twitter:title" content="<?php echo htmlspecialchars($project_name); ?>">
<meta property="twitter:description" content="<?php echo htmlspecialchars($project_description); ?>">
<meta property="twitter:image" content="<?php echo htmlspecialchars($project_image_url); ?>">
</head>
<body>
<!-- Header -->
<header>
<nav class="navbar navbar-expand-lg navbar-dark fixed-top">
<div class="container">
<a class="navbar-brand" href="index.php">
<i class="bi bi-broadcast"></i>
<?php echo htmlspecialchars($project_name); ?>
</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNav">
<ul class="navbar-nav ms-auto">
<li class="nav-item">
<a class="nav-link" href="index.php#home">Home</a>
</li>
<li class="nav-item">
<a class="nav-link" href="index.php#plans">Plans</a>
</li>
<li class="nav-item">
<a class="nav-link" href="index.php#business">Business</a>
</li>
<?php if (isset($_SESSION['user_id'])): ?>
<li class="nav-item">
<a class="nav-link" href="dashboard.php">Dashboard</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Hi, <?php echo htmlspecialchars($_SESSION['user_name']); ?></a>
</li>
<li class="nav-item">
<a class="nav-link" href="logout.php">Logout</a>
</li>
<?php else: ?>
<li class="nav-item">
<a class="nav-link" href="login.php">Login</a>
</li>
<li class="nav-item">
<a class="nav-link" href="register.php">Register</a>
</li>
<?php endif; ?>
</ul>
</div>
</div>
</nav>
</header>
<main>

267
index.php
View File

@ -1,150 +1,123 @@
<?php
declare(strict_types=1);
@ini_set('display_errors', '1');
@error_reporting(E_ALL);
@date_default_timezone_set('UTC');
<?php require_once 'includes/header.php'; ?>
$phpVersion = PHP_VERSION;
$now = date('Y-m-d H:i:s');
?>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>New Style</title>
<?php
// Read project preview data from environment
$projectDescription = $_SERVER['PROJECT_DESCRIPTION'] ?? '';
$projectImageUrl = $_SERVER['PROJECT_IMAGE_URL'] ?? '';
?>
<?php if ($projectDescription): ?>
<!-- Meta description -->
<meta name="description" content='<?= htmlspecialchars($projectDescription) ?>' />
<!-- Open Graph meta tags -->
<meta property="og:description" content="<?= htmlspecialchars($projectDescription) ?>" />
<!-- Twitter meta tags -->
<meta property="twitter:description" content="<?= htmlspecialchars($projectDescription) ?>" />
<?php endif; ?>
<?php if ($projectImageUrl): ?>
<!-- Open Graph image -->
<meta property="og:image" content="<?= htmlspecialchars($projectImageUrl) ?>" />
<!-- Twitter image -->
<meta property="twitter:image" content="<?= htmlspecialchars($projectImageUrl) ?>" />
<?php endif; ?>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;700&display=swap" rel="stylesheet">
<style>
:root {
--bg-color-start: #6a11cb;
--bg-color-end: #2575fc;
--text-color: #ffffff;
--card-bg-color: rgba(255, 255, 255, 0.01);
--card-border-color: rgba(255, 255, 255, 0.1);
}
body {
margin: 0;
font-family: 'Inter', sans-serif;
background: linear-gradient(45deg, var(--bg-color-start), var(--bg-color-end));
color: var(--text-color);
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
text-align: center;
overflow: hidden;
position: relative;
}
body::before {
content: '';
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100" viewBox="0 0 100 100"><path d="M-10 10L110 10M10 -10L10 110" stroke-width="1" stroke="rgba(255,255,255,0.05)"/></svg>');
animation: bg-pan 20s linear infinite;
z-index: -1;
}
@keyframes bg-pan {
0% { background-position: 0% 0%; }
100% { background-position: 100% 100%; }
}
main {
padding: 2rem;
}
.card {
background: var(--card-bg-color);
border: 1px solid var(--card-border-color);
border-radius: 16px;
padding: 2rem;
backdrop-filter: blur(20px);
-webkit-backdrop-filter: blur(20px);
box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.1);
}
.loader {
margin: 1.25rem auto 1.25rem;
width: 48px;
height: 48px;
border: 3px solid rgba(255, 255, 255, 0.25);
border-top-color: #fff;
border-radius: 50%;
animation: spin 1s linear infinite;
}
@keyframes spin {
from { transform: rotate(0deg); }
to { transform: rotate(360deg); }
}
.hint {
opacity: 0.9;
}
.sr-only {
position: absolute;
width: 1px; height: 1px;
padding: 0; margin: -1px;
overflow: hidden;
clip: rect(0, 0, 0, 0);
white-space: nowrap; border: 0;
}
h1 {
font-size: 3rem;
font-weight: 700;
margin: 0 0 1rem;
letter-spacing: -1px;
}
p {
margin: 0.5rem 0;
font-size: 1.1rem;
}
code {
background: rgba(0,0,0,0.2);
padding: 2px 6px;
border-radius: 4px;
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
footer {
position: absolute;
bottom: 1rem;
font-size: 0.8rem;
opacity: 0.7;
}
</style>
</head>
<body>
<main>
<div class="card">
<h1>Analyzing your requirements and generating your website…</h1>
<div class="loader" role="status" aria-live="polite" aria-label="Applying initial changes">
<span class="sr-only">Loading…</span>
<!-- Hero Section -->
<section id="home" class="hero-section">
<div class="container">
<h1>Connect Your World</h1>
<p class="lead">Reliable, fast, and seamless communication solutions for everyone.</p>
<a href="#plans" class="btn btn-primary">See Our Plans</a>
</div>
<p class="hint"><?= ($_SERVER['HTTP_HOST'] ?? '') === 'appwizzy.com' ? 'AppWizzy' : 'Flatlogic' ?> AI is collecting your requirements and applying the first changes.</p>
<p class="hint">This page will update automatically as the plan is implemented.</p>
<p>Runtime: PHP <code><?= htmlspecialchars($phpVersion) ?></code> — UTC <code><?= htmlspecialchars($now) ?></code></p>
</section>
<!-- Customer Segments Section -->
<section id="business" class="section bg-light">
<div class="container">
<h2 class="section-title">Built for Everyone</h2>
<div class="row g-4">
<!-- Residential -->
<div class="col-lg-4 d-flex align-items-stretch">
<div class="card segment-card text-center">
<div class="card-body">
<i class="bi bi-house-heart-fill fs-1 text-primary mb-3"></i>
<h3 class="card-title">Residential</h3>
<p class="card-text">High-speed internet and streaming for your home. Enjoy uninterrupted connectivity for work, school, and entertainment.</p>
<a href="#" class="btn btn-outline-primary mt-auto">Learn More</a>
</div>
</main>
<footer>
Page updated: <?= htmlspecialchars($now) ?> (UTC)
</footer>
</body>
</html>
</div>
</div>
<!-- Small Business -->
<div class="col-lg-4 d-flex align-items-stretch">
<div class="card segment-card text-center">
<div class="card-body">
<i class="bi bi-briefcase-fill fs-1 text-primary mb-3"></i>
<h3 class="card-title">Small Business</h3>
<p class="card-text">Affordable and scalable solutions to power your business growth. Keep your team connected and productive.</p>
<a href="#" class="btn btn-outline-primary mt-auto">Discover Solutions</a>
</div>
</div>
</div>
<!-- Enterprise -->
<div class="col-lg-4 d-flex align-items-stretch">
<div class="card segment-card text-center">
<div class="card-body">
<i class="bi bi-building-fill fs-1 text-primary mb-3"></i>
<h3 class="card-title">Enterprise</h3>
<p class="card-text">Dedicated fiber, cloud services, and robust infrastructure for large-scale operations. Mission-critical reliability.</p>
<a href="#" class="btn btn-outline-primary mt-auto">Explore Services</a>
</div>
</div>
</div>
</div>
</div>
</section>
<!-- Plans Section -->
<section id="plans" class="section">
<div class="container">
<h2 class="section-title">Our Plans</h2>
<div class="row justify-content-center g-4">
<!-- Basic Plan -->
<div class="col-lg-4">
<div class="card pricing-card h-100">
<div class="card-header text-center">
<h3>Starter</h3>
</div>
<div class="card-body text-center">
<p class="price">$29.99<span class="period">/mo</span></p>
<ul class="list-unstyled">
<li><i class="bi bi-check-circle-fill text-primary"></i> 100 Mbps Download</li>
<li><i class="bi bi-check-circle-fill text-primary"></i> Unlimited Data</li>
<li><i class="bi bi-x-circle"></i> HD Streaming</li>
<li><i class="bi bi-x-circle"></i> 24/7 Priority Support</li>
</ul>
</div>
<div class="card-footer text-center">
<a href="#" class="btn btn-outline-primary">Sign Up</a>
</div>
</div>
</div>
<!-- Pro Plan (Featured) -->
<div class="col-lg-4">
<div class="card pricing-card featured h-100">
<div class="card-header text-center">
<h3>Pro Fiber</h3>
</div>
<div class="card-body text-center">
<p class="price">$59.99<span class="period">/mo</span></p>
<ul class="list-unstyled">
<li><i class="bi bi-check-circle-fill text-primary"></i> 1 Gbps Symmetric</li>
<li><i class="bi bi-check-circle-fill text-primary"></i> Unlimited Data</li>
<li><i class="bi bi-check-circle-fill text-primary"></i> 4K Streaming</li>
<li><i class="bi bi-check-circle-fill text-primary"></i> 24/7 Priority Support</li>
</ul>
</div>
<div class="card-footer text-center">
<a href="#" class="btn btn-primary">Sign Up</a>
</div>
</div>
</div>
<!-- Business Plan -->
<div class="col-lg-4">
<div class="card pricing-card h-100">
<div class="card-header text-center">
<h3>Business Ultimate</h3>
</div>
<div class="card-body text-center">
<p class="price">$99.99<span class="period">/mo</span></p>
<ul class="list-unstyled">
<li><i class="bi bi-check-circle-fill text-primary"></i> 2 Gbps Symmetric</li>
<li><i class="bi bi-check-circle-fill text-primary"></i> Unlimited Data</li>
<li><i class="bi bi-check-circle-fill text-primary"></i> Dedicated Account Rep</li>
<li><i class="bi bi-check-circle-fill text-primary"></i> SLA Guarantee</li>
</ul>
</div>
<div class="card-footer text-center">
<a href="#" class="btn btn-outline-primary">Sign Up</a>
</div>
</div>
</div>
</div>
</div>
</section>
<?php require_once 'includes/footer.php'; ?>

88
login.php Normal file
View File

@ -0,0 +1,88 @@
<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
require_once 'db/config.php';
$errors = [];
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$email = trim($_POST['email']);
$password = $_POST['password'];
if (empty($email)) {
$errors[] = 'Email is required';
}
if (empty($password)) {
$errors[] = 'Password is required';
}
if (empty($errors)) {
$pdo = db();
$stmt = $pdo->prepare("SELECT * FROM users WHERE email = ?");
$stmt->execute([$email]);
$user = $stmt->fetch();
if ($user) {
echo "User found. ";
if (password_verify($password, $user['password_hash'])) {
$_SESSION['user_id'] = $user['id'];
$_SESSION['user_name'] = $user['name'];
header("Location: dashboard.php");
exit;
} else {
echo "Password verification failed.";
die();
$errors[] = 'Invalid password';
}
} else {
echo "No user found.";
die();
$errors[] = 'No user found with that email address';
}
}
}
require_once 'includes/header.php';
?>
<div class="container mt-5 pt-5">
<div class="row justify-content-center">
<div class="col-md-6">
<div class="card">
<div class="card-header">
<h3 class="text-center">Login</h3>
</div>
<div class="card-body">
<?php if (!empty($errors)): ?>
<div class="alert alert-danger">
<?php foreach ($errors as $error): ?>
<p><?php echo $error; ?></p>
<?php endforeach; ?>
</div>
<?php endif; ?>
<form action="login.php" method="POST">
<div class="mb-3">
<label for="email" class="form-label">Email address</label>
<input type="email" class="form-control" id="email" name="email" required>
</div>
<div class="mb-3">
<label for="password" class="form-label">Password</label>
<input type="password" class="form-control" id="password" name="password" required>
</div>
<div class="d-grid">
<button type="submit" class="btn btn-primary">Login</button>
</div>
</form>
</div>
<div class="card-footer text-center">
<p>Don't have an account? <a href="register.php">Register here</a></p>
</div>
</div>
</div>
</div>
</div>
<?php require_once 'includes/footer.php'; ?>

6
logout.php Normal file
View File

@ -0,0 +1,6 @@
<?php
session_start();
session_unset();
session_destroy();
header("Location: index.php");
exit;

107
register.php Normal file
View File

@ -0,0 +1,107 @@
<?php
require_once 'db/config.php';
$errors = [];
$success = '';
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$name = trim($_POST['name']);
$email = trim($_POST['email']);
$password = $_POST['password'];
$confirm_password = $_POST['confirm_password'];
if (empty($name)) {
$errors[] = 'Name is required';
}
if (empty($email)) {
$errors[] = 'Email is required';
} elseif (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
$errors[] = 'Invalid email format';
}
if (empty($password)) {
$errors[] = 'Password is required';
} elseif (strlen($password) < 8) {
$errors[] = 'Password must be at least 8 characters long';
}
if ($password !== $confirm_password) {
$errors[] = 'Passwords do not match';
}
if (empty($errors)) {
$pdo = db();
$stmt = $pdo->prepare("SELECT * FROM users WHERE email = ?");
$stmt->execute([$email]);
$existing_user = $stmt->fetch();
if ($existing_user) {
$errors[] = 'Email already exists';
} else {
$password_hash = password_hash($password, PASSWORD_DEFAULT);
$stmt = $pdo->prepare("INSERT INTO users (name, email, password_hash) VALUES (?, ?, ?)");
if ($stmt->execute([$name, $email, $password_hash])) {
$success = "Registration successful! You can now <a href='login.php'>login</a>.";
} else {
$errors[] = 'Failed to register. Please try again.';
}
}
}
}
require_once 'includes/header.php';
?>
<div class="container mt-5 pt-5">
<div class="row justify-content-center">
<div class="col-md-6">
<div class="card">
<div class="card-header">
<h3 class="text-center">Register</h3>
</div>
<div class="card-body">
<?php if (!empty($errors)): ?>
<div class="alert alert-danger">
<?php foreach ($errors as $error): ?>
<p><?php echo $error; ?></p>
<?php endforeach; ?>
</div>
<?php endif; ?>
<?php if (!empty($success)): ?>
<div class="alert alert-success">
<p><?php echo $success; ?></p>
</div>
<?php else: ?>
<form action="register.php" method="POST">
<div class="mb-3">
<label for="name" class="form-label">Name</label>
<input type="text" class="form-control" id="name" name="name" required value="<?php echo isset($_POST['name']) ? htmlspecialchars($_POST['name']) : ''; ?>">
</div>
<div class="mb-3">
<label for="email" class="form-label">Email address</label>
<input type="email" class="form-control" id="email" name="email" required value="<?php echo isset($_POST['email']) ? htmlspecialchars($_POST['email']) : ''; ?>">
</div>
<div class="mb-3">
<label for="password" class="form-label">Password</label>
<input type="password" class="form-control" id="password" name="password" required>
</div>
<div class="mb-3">
<label for="confirm_password" class="form-label">Confirm Password</label>
<input type="password" class="form-control" id="confirm_password" name="confirm_password" required>
</div>
<div class="d-grid">
<button type="submit" class="btn btn-primary">Register</button>
</div>
</form>
<?php endif; ?>
</div>
<div class="card-footer text-center">
<p>Already have an account? <a href="login.php">Login here</a></p>
</div>
</div>
</div>
</div>
</div>
<?php require_once 'includes/footer.php'; ?>

45
subscribe.php Normal file
View File

@ -0,0 +1,45 @@
<?php
require_once 'includes/header.php';
require_once 'db/config.php';
if (!isset($_SESSION['user_id'])) {
header('Location: login.php');
exit;
}
if (isset($_GET['service_id'])) {
$service_id = $_GET['service_id'];
$user_id = $_SESSION['user_id'];
try {
$pdo = db();
// Check if the user is already subscribed
$stmt = $pdo->prepare("SELECT * FROM user_services WHERE user_id = ? AND service_id = ? AND status = 'active'");
$stmt->execute([$user_id, $service_id]);
if ($stmt->rowCount() > 0) {
$message = "You are already subscribed to this service.";
} else {
// Add the subscription
$stmt = $pdo->prepare("INSERT INTO user_services (user_id, service_id) VALUES (?, ?)");
$stmt->execute([$user_id, $service_id]);
$message = "You have successfully subscribed to the service!";
}
} catch (PDOException $e) {
$message = "An error occurred: " . $e->getMessage();
}
} else {
header('Location: dashboard.php');
exit;
}
?>
<div class="container mt-5">
<div class="alert alert-info">
<?php echo htmlspecialchars($message); ?>
</div>
<a href="dashboard.php" class="btn btn-primary">Back to Dashboard</a>
</div>
<?php require_once 'includes/footer.php'; ?>