added old projects

This commit is contained in:
Austin Bennett
2026-02-03 08:18:39 -06:00
parent 43acf989bf
commit 2451448b8a
623 changed files with 28117 additions and 0 deletions
+7
View File
@@ -0,0 +1,7 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 3
[[package]]
name = "mtr_server_app"
version = "0.1.0"
+8
View File
@@ -0,0 +1,8 @@
[package]
name = "mtr_server_app"
version = "0.1.0"
edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
+285
View File
@@ -0,0 +1,285 @@
-- phpMyAdmin SQL Dump
-- version 5.2.1
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1
-- Generation Time: Apr 04, 2024 at 01:19 AM
-- Server version: 10.4.32-MariaDB
-- PHP Version: 8.0.30
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
START TRANSACTION;
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
--
-- Database: `flab_u_less`
--
-- --------------------------------------------------------
--
-- Table structure for table `attendance`
--
CREATE TABLE `attendance` (
`id` int(11) NOT NULL,
`member_id` int(11) DEFAULT NULL,
`check_in` datetime DEFAULT NULL,
`attendance_type` varchar(255) DEFAULT NULL,
`reference_id` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
--
-- Dumping data for table `attendance`
--
INSERT INTO `attendance` (`id`, `member_id`, `check_in`, `attendance_type`, `reference_id`) VALUES
(401, 1, '2022-01-10 07:50:00', 'Class', 101),
(402, 2, '2022-06-18 15:50:00', 'Personal Training', 202),
(403, 3, '2022-02-14 09:50:00', 'Class', 103),
(404, 4, '2022-03-21 16:50:00', 'Personal Training', 204),
(405, 5, '2022-04-22 11:50:00', 'Personal Training', 205);
-- --------------------------------------------------------
--
-- Table structure for table `booking`
--
CREATE TABLE `booking` (
`id` int(11) NOT NULL,
`member_id` int(11) DEFAULT NULL,
`booking_date` date DEFAULT NULL,
`booking_type` varchar(255) DEFAULT NULL,
`reference_id` int(11) DEFAULT NULL,
`status` varchar(255) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
--
-- Dumping data for table `booking`
--
INSERT INTO `booking` (`id`, `member_id`, `booking_date`, `booking_type`, `reference_id`, `status`) VALUES
(1, 1, '2022-01-03', 'Class', 101, 'Booked'),
(2, 2, '2022-06-17', 'Personal Training', 102, 'Cancelled'),
(3, 3, '2022-02-03', 'Facility Reservation', 301, 'Booked'),
(4, 4, '2022-03-03', 'Class', 102, 'Booked'),
(5, 5, '2022-04-03', 'Personal Training', 202, 'Cancelled');
-- --------------------------------------------------------
--
-- Table structure for table `class`
--
CREATE TABLE `class` (
`id` int(11) NOT NULL,
`name` varchar(255) DEFAULT NULL,
`instructor` varchar(255) DEFAULT NULL,
`start_time` datetime DEFAULT NULL,
`end_time` datetime DEFAULT NULL,
`max_participants` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
--
-- Dumping data for table `class`
--
INSERT INTO `class` (`id`, `name`, `instructor`, `start_time`, `end_time`, `max_participants`) VALUES
(101, 'Yoga Basics', 'Alice Johnson', '2022-01-10 08:00:00', '2022-01-10 09:00:00', 20),
(102, 'Advanced Cycling', 'Bob Brown', '2022-01-11 17:00:00', '2022-01-11 18:30:00', 15),
(103, 'Strength Training', 'Daniel Grey', '2022-02-14 10:00:00', '2022-02-14 11:00:00', 10),
(104, 'Pilates Beginner', 'Eva Black', '2022-03-15 14:00:00', '2022-03-15 15:00:00', 12),
(105, 'Kickboxing', 'Frank White', '2022-04-16 18:00:00', '2022-04-16 19:30:00', 8);
-- --------------------------------------------------------
--
-- Table structure for table `facility_reservation`
--
CREATE TABLE `facility_reservation` (
`id` int(11) NOT NULL,
`facility_name` varchar(255) DEFAULT NULL,
`reserved_from` datetime DEFAULT NULL,
`reserved_to` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
--
-- Dumping data for table `facility_reservation`
--
INSERT INTO `facility_reservation` (`id`, `facility_name`, `reserved_from`, `reserved_to`) VALUES
(301, 'Tennis Court', '2022-01-13 13:00:00', '2022-01-13 15:00:00'),
(302, 'Squash Court', '2022-06-19 09:00:00', '2022-06-19 10:00:00'),
(303, 'Basketball Court', '2022-02-23 16:00:00', '2022-02-23 18:00:00'),
(304, 'Swimming Pool', '2022-03-24 10:00:00', '2022-03-24 12:00:00'),
(305, 'Volleyball Court', '2022-04-25 14:00:00', '2022-04-25 16:00:00');
-- --------------------------------------------------------
--
-- Table structure for table `member`
--
CREATE TABLE `member` (
`id` int(11) NOT NULL,
`name` varchar(255) DEFAULT NULL,
`email` varchar(255) DEFAULT NULL,
`phone` varchar(255) DEFAULT NULL,
`join_date` date DEFAULT NULL,
`membership_status` varchar(255) DEFAULT NULL,
`payment_info` varchar(255) DEFAULT NULL,
`communication_preferences` varchar(255) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
--
-- Dumping data for table `member`
--
INSERT INTO `member` (`id`, `name`, `email`, `phone`, `join_date`, `membership_status`, `payment_info`, `communication_preferences`) VALUES
(1, 'John Doe', '[email protected]', '123-456-7890', '2022-01-01', 'Active', 'Credit Card', 'Email'),
(2, 'Jane Smith', '[email protected]', '098-765-4321', '2022-06-15', 'Inactive', 'PayPal', 'SMS'),
(3, 'Emily Clark', '[email protected]', '321-654-9870', '2022-02-01', 'Active', 'Debit Card', 'Email'),
(4, 'Michael Brown', '[email protected]', '654-321-0987', '2022-03-01', 'Active', 'Bank Transfer', 'Phone'),
(5, 'Olivia Green', '[email protected]', '987-654-3210', '2022-04-01', 'Inactive', 'Cash', 'SMS');
-- --------------------------------------------------------
--
-- Table structure for table `payment`
--
CREATE TABLE `payment` (
`id` int(11) NOT NULL,
`member_id` int(11) DEFAULT NULL,
`payment_date` date DEFAULT NULL,
`amount` float DEFAULT NULL,
`payment_method` varchar(255) DEFAULT NULL,
`status` varchar(255) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
--
-- Dumping data for table `payment`
--
INSERT INTO `payment` (`id`, `member_id`, `payment_date`, `amount`, `payment_method`, `status`) VALUES
(1, 1, '2022-01-02', 100, 'Credit Card', 'Completed'),
(2, 2, '2022-06-16', 50, 'PayPal', 'Pending'),
(3, 3, '2022-02-02', 75, 'Debit Card', 'Completed'),
(4, 4, '2022-03-02', 80, 'Bank Transfer', 'Completed'),
(5, 5, '2022-04-02', 65, 'Cash', 'Pending');
-- --------------------------------------------------------
--
-- Table structure for table `personal_training_session`
--
CREATE TABLE `personal_training_session` (
`id` int(11) NOT NULL,
`member_id` int(11) DEFAULT NULL,
`trainer` varchar(255) DEFAULT NULL,
`start_time` datetime DEFAULT NULL,
`end_time` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
--
-- Dumping data for table `personal_training_session`
--
INSERT INTO `personal_training_session` (`id`, `member_id`, `trainer`, `start_time`, `end_time`) VALUES
(201, 1, 'Carol White', '2022-01-12 10:00:00', '2022-01-12 11:00:00'),
(202, 2, 'Dave Black', '2022-06-18 16:00:00', '2022-06-18 17:00:00'),
(203, 3, 'Gina Blue', '2022-02-20 09:00:00', '2022-02-20 10:00:00'),
(204, 4, 'Hank Green', '2022-03-21 17:00:00', '2022-03-21 18:00:00'),
(205, 5, 'Ivy Gold', '2022-04-22 12:00:00', '2022-04-22 13:00:00');
--
-- Indexes for dumped tables
--
--
-- Indexes for table `attendance`
--
ALTER TABLE `attendance`
ADD PRIMARY KEY (`id`),
ADD KEY `member_id` (`member_id`);
--
-- Indexes for table `booking`
--
ALTER TABLE `booking`
ADD PRIMARY KEY (`id`),
ADD KEY `member_id` (`member_id`);
--
-- Indexes for table `class`
--
ALTER TABLE `class`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `facility_reservation`
--
ALTER TABLE `facility_reservation`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `member`
--
ALTER TABLE `member`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `payment`
--
ALTER TABLE `payment`
ADD PRIMARY KEY (`id`),
ADD KEY `member_id` (`member_id`);
--
-- Indexes for table `personal_training_session`
--
ALTER TABLE `personal_training_session`
ADD PRIMARY KEY (`id`),
ADD KEY `member_id` (`member_id`);
--
-- Constraints for dumped tables
--
--
-- Constraints for table `attendance`
--
ALTER TABLE `attendance`
ADD CONSTRAINT `attendance_ibfk_1` FOREIGN KEY (`member_id`) REFERENCES `member` (`id`);
--
-- Constraints for table `booking`
--
ALTER TABLE `booking`
ADD CONSTRAINT `booking_ibfk_1` FOREIGN KEY (`member_id`) REFERENCES `member` (`id`);
--
-- Constraints for table `payment`
--
ALTER TABLE `payment`
ADD CONSTRAINT `payment_ibfk_1` FOREIGN KEY (`member_id`) REFERENCES `member` (`id`);
--
-- Constraints for table `personal_training_session`
--
ALTER TABLE `personal_training_session`
ADD CONSTRAINT `personal_training_session_ibfk_1` FOREIGN KEY (`member_id`) REFERENCES `member` (`id`);
COMMIT;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
+11
View File
@@ -0,0 +1,11 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Hello!</title>
</head>
<body>
<h1>Oops!</h1>
<p>Sorry, I don't know what you're asking for.</p>
</body>
</html>
@@ -0,0 +1,20 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Admin Dashboard</title>
</head>
<body>
<h1>Admin Dashboard</h1>
<nav>
<ul>
<li><a href="/admin/members.html">Manage Members</a></li>
<li><a href="/admin/classes.html">Manage Classes</a></li>
<li><a href="/admin/bookings.html">Manage Bookings</a></li>
<li><a href="/admin/payments.html">Manage Payments</a></li>
<li><a href="/admin/facilities.html">Manage Facilities</a></li>
<li><a href="/admin/reports.html">View Reports</a></li>
</ul>
</nav>
</body>
</html>
@@ -0,0 +1,25 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Manage Members</title>
</head>
<body>
<h1>Manage Members</h1>
<table>
<thead>
<tr>
<th>ID</th>
<th>Name</th>
<th>Email</th>
<th>Phone</th>
<th>Status</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
<!-- Member records will be inserted here dynamically -->
</tbody>
</table>
</body>
</html>
@@ -0,0 +1,22 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Reports</title>
</head>
<body>
<h1>Reports</h1>
<section>
<h2>Financial Reports</h2>
<!-- Financial report content -->
</section>
<section>
<h2>Attendance Reports</h2>
<!-- Attendance report content -->
</section>
<section>
<h2>Booking Reports</h2>
<!-- Booking report content -->
</section>
</body>
</html>
@@ -0,0 +1,11 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Hello!</title>
</head>
<body>
<h1>Yeet!</h1>
<p>index.html</p>
</body>
</html>
@@ -0,0 +1,19 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Member Login</title>
</head>
<body>
<h1>Member Login</h1>
<form action="/login" method="post">
<label for="email">Email:</label>
<input type="email" id="email" name="email" required>
<label for="password">Password:</label>
<input type="password" id="password" name="password" required>
<button type="submit">Login</button>
</form>
</body>
</html>
@@ -0,0 +1,29 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Member Profile</title>
</head>
<body>
<h1>Member Profile</h1>
<form action="/update-profile" method="post">
<label for="name">Name:</label>
<input type="text" id="name" name="name" required>
<label for="email">Email:</label>
<input type="email" id="email" name="email" required>
<label for="phone">Phone:</label>
<input type="tel" id="phone" name="phone" required>
<label for="communication_preferences">Communication Preferences:</label>
<select id="communication_preferences" name="communication_preferences" required>
<option value="Email">Email</option>
<option value="SMS">SMS</option>
<option value="Phone">Phone</option>
</select>
<button type="submit">Update Profile</button>
</form>
</body>
</html>
@@ -0,0 +1,31 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Member Registration</title>
</head>
<body>
<h1>Member Registration</h1>
<form action="\scripts\register_member.php" method="post">
<label for="name">Name:</label>
<input type="text" id="name" name="name" required>
<label for="email">Email:</label>
<input type="email" id="email" name="email" required>
<label for="phone">Phone:</label>
<input type="tel" id="phone" name="phone" required>
<label for="join_date">Join Date:</label>
<input type="date" id="join_date" name="join_date" required>
<label for="membership_status">Membership Status:</label>
<select id="membership_status" name="membership_status" required>
<option value="Active">Active</option>
<option value="Inactive">Inactive</option>
</select>
<button type="submit">Register</button>
</form>
</body>
</html>
@@ -0,0 +1,23 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Payment History</title>
</head>
<body>
<h1>Payment History</h1>
<table>
<thead>
<tr>
<th>Date</th>
<th>Amount</th>
<th>Method</th>
<th>Status</th>
</tr>
</thead>
<tbody>
<!-- Payment records will be inserted here dynamically -->
</tbody>
</table>
</body>
</html>
@@ -0,0 +1,25 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Make a Payment</title>
</head>
<body>
<h1>Make a Payment</h1>
<form action="/process-payment" method="post">
<label for="amount">Amount:</label>
<input type="number" id="amount" name="amount" step="0.01" required>
<label for="payment_method">Payment Method:</label>
<select id="payment_method" name="payment_method" required>
<option value="Credit Card">Credit Card</option>
<option value="Debit Card">Debit Card</option>
<option value="PayPal">PayPal</option>
<option value="Bank Transfer">Bank Transfer</option>
<option value="Cash">Cash</option>
</select>
<button type="submit">Pay Now</button>
</form>
</body>
</html>
@@ -0,0 +1,39 @@
<?php
$servername = "localhost";
$username = "user";
$password = "password";
$dbname = "flab_u_less";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
// prepare and bind
$stmt = $conn->prepare("INSERT INTO MyGuests (firstname, lastname, email) VALUES (?, ?, ?)");
$stmt->bind_param("sss", $firstname, $lastname, $email);
// set parameters and execute
$firstname = "John";
$lastname = "Doe";
$email = "[email protected]";
$stmt->execute();
$firstname = "Mary";
$lastname = "Moe";
$email = "[email protected]";
$stmt->execute();
$firstname = "Julie";
$lastname = "Dooley";
$email = "[email protected]";
$stmt->execute();
echo "New records created successfully";
$stmt->close();
$conn->close();
?>
+4
View File
@@ -0,0 +1,4 @@
**to run the web server**
1. install [rust](https://www.rust-lang.org/tools/install)
2. ```cargo run``` inside directory
3. edit files inside `public/`
+46
View File
@@ -0,0 +1,46 @@
use std::net::TcpListener;
use std::net::TcpStream;
use std::io::prelude::*;
use std::fs;
use mtr_server_app::ThreadPool;
fn main() {
let listener = TcpListener::bind("127.0.0.1:7878").unwrap();
let pool = ThreadPool::new(4);
for stream in listener.incoming() {
let stream = stream.unwrap();
pool.execute(|| {
handle_connection(stream);
});
}
}
fn handle_connection(mut stream: TcpStream) {
let mut buffer = [0; 1024];
stream.read(&mut buffer).unwrap();
let request = std::str::from_utf8(&buffer).unwrap_or_default();
let request_line = request.lines().next().unwrap_or_default();
let request_parts: Vec<&str> = request_line.split_whitespace().collect();
if request_parts.len() < 2 {
return;
}
let requested_path = request_parts[1];
let mut path = format!("public{}", requested_path);
let status_line = if fs::metadata(&path).is_ok() {
"HTTP/1.1 200 OK"
} else {
path = "./public/404.html".to_string();
"HTTP/1.1 404 NOT FOUND"
};
let contents = fs::read_to_string(&path).unwrap_or_else(|_| "Error loading file".to_string());
let response = format!("{}\r\nContent-Length: {}\r\n\r\n{}", status_line, contents.len(), contents);
stream.write(response.as_bytes()).unwrap();
stream.flush().unwrap();
}
+98
View File
@@ -0,0 +1,98 @@
use std::thread;
use std::sync::mpsc;
use std::sync::Arc;
use std::sync::Mutex;
enum Message {
NewJob(Job),
Terminate
}
pub struct ThreadPool {
workers: Vec<Worker>,
sender: mpsc::Sender<Message>
}
type Job = Box<dyn FnOnce() + Send + 'static>;
impl ThreadPool {
/// Create a new ThreadPool.
///
/// The size is the number of threads in the pool.
///
/// # Panics
///
/// The `new` function will panic if the size is zero.
pub fn new(size: usize) -> ThreadPool {
assert!(size > 0);
let (sender, receiver) = mpsc::channel();
let receiver = Arc::new(Mutex::new(receiver));
let mut workers = Vec::with_capacity(size);
for id in 0..size {
workers.push(Worker::new(id, Arc::clone(&receiver)));
}
ThreadPool{workers, sender}
}
pub fn execute<F> (&self, f: F)
where F : FnOnce() + Send + 'static, {
let job = Box::new(f);
self.sender.send(Message::NewJob(job)).unwrap();
}
}
impl Drop for ThreadPool {
fn drop (&mut self) {
println!("Sending terminate message to all workers.");
for _ in &self.workers {
self.sender.send(Message::Terminate).unwrap();
}
for worker in &mut self.workers {
println!("Shutting down Worker {}", worker.id);
// worker.thread.join().unwrap();
if let Some(thread) = worker.thread.take() {
thread.join().unwrap();
}
}
}
}
struct Worker {
id: usize,
thread: Option<thread::JoinHandle<()>>
}
impl Worker {
fn new(id: usize, receiver: Arc<Mutex<mpsc::Receiver<Message>>>) -> Worker {
let thread = thread::spawn(move || loop {
let message = receiver.lock().unwrap().recv().unwrap();
// println!("Worker {} got a job. Executing...", id);
match message {
Message::NewJob(job) => {
println!("Worker {} got a job. Executing...", id);
job();
}
Message::Terminate => {
println!("Worker {} was told to terminate.", id);
break;
}
}
});
Worker {
id,
thread: Some(thread),
}
}
}
+79
View File
@@ -0,0 +1,79 @@
<?php
session_start();
// Check if the user is logged in
if (!isset($_SESSION['user_id'])) {
header("Location: index.php"); // Redirect to login page if not logged in
exit;
}
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "flab_u_less";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$memberId = $_SESSION['user_id']; // Get user ID from session
// Fetch user's bookings
$sql = "SELECT b.*, c.name AS class_name FROM booking b LEFT JOIN class c ON b.reference_id = c.id WHERE b.member_id = ?";
$stmt = $conn->prepare($sql);
$stmt->bind_param("i", $memberId);
$stmt->execute();
$result = $stmt->get_result();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Manage Bookings</title>
</head>
<body>
<h1>Your Bookings</h1>
<?php if ($result->num_rows > 0): ?>
<table border="1">
<tr>
<th>Booking ID</th>
<th>Class Name</th>
<th>Booking Date</th>
<th>Status</th>
</tr>
<?php while ($row = $result->fetch_assoc()): ?>
<tr>
<td><?= htmlspecialchars($row['id']) ?></td>
<td><?= htmlspecialchars($row['class_name']) ?></td>
<td><?= htmlspecialchars($row['booking_date']) ?></td>
<td><?= htmlspecialchars($row['status']) ?></td>
</tr>
<?php endwhile; ?>
</table>
<?php else: ?>
<p>No bookings found.</p>
<?php endif; ?>
<h2>Book a Class</h2>
<form action="make_booking.php" method="post">
<label for="class">Class:</label>
<select name="class_id" id="class">
<?php
// Fetch and display classes for booking
$sql = "SELECT id, name FROM class";
$result = $conn->query($sql);
while ($row = $result->fetch_assoc()) {
echo "<option value='" . $row['id'] . "'>" . $row['name'] . "</option>";
}
?>
</select>
<br>
<input type="submit" value="Book Class">
</form>
</body>
</html>
+53
View File
@@ -0,0 +1,53 @@
<?php
session_start();
// Check if the user is logged in
if (!isset($_SESSION['user_id'])) {
// Redirect to login page if the user is not logged in
header("Location: index.php");
exit;
}
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "flab_u_less";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
// Fetch class schedule from database
$sql = "SELECT * FROM class ORDER BY start_time";
$result = $conn->query($sql);
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Class Schedule</title>
</head>
<body>
<h1>Class Schedule</h1>
<?php
if ($result->num_rows > 0) {
echo "<table border='1'>";
echo "<tr><th>Class Name</th><th>Instructor</th><th>Start Time</th><th>End Time</th><th>Max Participants</th></tr>";
while($row = $result->fetch_assoc()) {
echo "<tr><td>" . $row["name"] . "</td><td>" . $row["instructor"] . "</td><td>"
. $row["start_time"] . "</td><td>" . $row["end_time"] . "</td><td>"
. $row["max_participants"] . "</td></tr>";
}
echo "</table>";
} else {
echo "No classes are available.";
}
$conn->close();
?>
</body>
</html>
+14
View File
@@ -0,0 +1,14 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Login Page</title>
</head>
<body>
<form action="login.php" method="post">
Email: <input type="text" name="email"><br>
Password: <input type="password" name="password"><br>
<input type="submit" value="Login">
</form>
</body>
</html>
+39
View File
@@ -0,0 +1,39 @@
<?php
session_start(); // Start the session at the beginning of the script
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "flab_u_less";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
// Get user input
$user_email = $_POST['email']; // Assuming you're logging in with email
$user_password = $_POST['password'];
// Prepare SQL statement to prevent SQL injection
$sql = "SELECT id FROM member WHERE email = ? AND password = ?";
$stmt = $conn->prepare($sql);
$stmt->bind_param("ss", $user_email, $user_password);
// Execute and check results
$stmt->execute();
$result = $stmt->get_result();
if ($result->num_rows > 0) {
$row = $result->fetch_assoc();
$_SESSION['user_id'] = $row['id']; // Store user ID in session
header("Location: welcome.php"); // Redirect to welcome page
} else {
// Login failed
echo "Invalid email or password";
}
$conn->close();
?>
+40
View File
@@ -0,0 +1,40 @@
<?php
session_start();
// Check if the user is logged in and the form was submitted
if (!isset($_SESSION['user_id']) || !isset($_POST['class_id'])) {
header("Location: index.php"); // Redirect to login page if not logged in or form not submitted
exit;
}
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "flab_u_less";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$memberId = $_SESSION['user_id']; // Get user ID from session
$classId = $_POST['class_id']; // Get class ID from submitted form
$bookingDate = date("Y-m-d"); // Use current date for booking date or fetch from a form if necessary
$status = "Booked"; // Default status
// Insert the booking into the database
$sql = "INSERT INTO booking (member_id, booking_date, booking_type, reference_id, status) VALUES (?, ?, 'Class', ?, ?)";
$stmt = $conn->prepare($sql);
$stmt->bind_param("issi", $memberId, $bookingDate, $classId, $status);
if ($stmt->execute()) {
echo "Booking successful!";
} else {
echo "Error: " . $stmt->error;
}
$conn->close();
?>
+50
View File
@@ -0,0 +1,50 @@
<?php
session_start(); // Start the session
// Check if the user is logged in
if (isset($_SESSION['user_id'])) {
$userId = $_SESSION['user_id']; // Now you have the user ID for the logged-in user
// You can use $userId to query the database or for any other purpose
} else {
// Redirect to login page or show an error message
header("Location: index.php"); // Assuming 'index.php' is your login page
exit;
}
$servername = "localhost";
$dbUsername = "root";
$dbPassword = "";
$dbname = "flab_u_less";
// Create connection
$conn = new mysqli($servername, $dbUsername, $dbPassword, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$memberId = $_SESSION['user_id']; // Get the member ID from session
// SQL to fetch personal training sessions for the logged-in user
$sql = "SELECT * FROM personal_training_session WHERE member_id = ?";
$stmt = $conn->prepare($sql);
$stmt->bind_param("i", $memberId);
$stmt->execute();
$result = $stmt->get_result();
// Check if there are any sessions and display them
if ($result->num_rows > 0) {
echo "<h1>Your Upcoming Personal Training Sessions</h1>";
while($row = $result->fetch_assoc()) {
echo "Session ID: " . $row["id"] . "<br>";
echo "Trainer: " . $row["trainer"] . "<br>";
echo "Start Time: " . $row["start_time"] . "<br>";
echo "End Time: " . $row["end_time"] . "<br><hr>";
}
} else {
echo "No upcoming sessions found.";
}
$conn->close();
?>
+58
View File
@@ -0,0 +1,58 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Welcome</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
background-color: #f4f4f4;
}
.container {
max-width: 800px;
margin: auto;
padding: 20px;
background-color: #fff;
border-radius: 5px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}
h1 {
color: #333;
}
ul {
list-style-type: none;
padding: 0;
}
li {
padding: 10px;
margin: 5px 0;
background-color: #007bff;
color: white;
border-radius: 5px;
}
li a {
color: white;
text-decoration: none;
display: block;
}
li a:hover {
background-color: #0056b3;
}
</style>
</head>
<body>
<div class="container">
<h1>Welcome to the Fitness Center!</h1>
<p>Select from the options below:</p>
<ul>
<li><a href="view_sessions.php">View Personal Training Sessions</a></li>
<li><a href="class_schedule.php">Check Class Schedule</a></li>
<li><a href="booking.php">Manage Bookings</a></li>
<li><a href="profile.php">Update Personal Information</a></li>
<li><a href="payment_history.php">View Payment History</a></li>
</ul>
</div>
</body>
</html>