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
+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>