I'm in a rush to release so I am adding features that are needed to make it usable.
This commit is contained in:
parent
c76ab1abf3
commit
4c2857b445
25 changed files with 2475 additions and 3475 deletions
278
profile.php
Normal file
278
profile.php
Normal file
|
@ -0,0 +1,278 @@
|
|||
<?php
|
||||
// profile.php
|
||||
|
||||
require_once 'includes/globals.php';
|
||||
require_once 'vendor/autoload.php';
|
||||
|
||||
// Make sure the user is authenticated; otherwise redirect to login.
|
||||
if (!isset($_SESSION['user'])) {
|
||||
header("Location: login.php");
|
||||
exit;
|
||||
}
|
||||
|
||||
use DJMixHosting\Database;
|
||||
$db = new Database($config);
|
||||
|
||||
// Retrieve the full user record from the database
|
||||
$userId = $_SESSION['user']['id'];
|
||||
$stmt = $db->prepare("SELECT * FROM users WHERE id = ?");
|
||||
$stmt->bind_param("i", $userId);
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
$userData = $result->fetch_assoc();
|
||||
$stmt->close();
|
||||
|
||||
// Determine if editing should be disabled (if email not verified)
|
||||
$editingDisabled = (int)$userData['emailVerified'] !== 1; // Assuming 1 means verified
|
||||
|
||||
// Optionally, set a flag for showing an alert to verify email.
|
||||
$alertMessage = "";
|
||||
if ($editingDisabled) {
|
||||
$alertMessage = "Please verify your email to enable profile editing.";
|
||||
}
|
||||
|
||||
require_once 'includes/header.php';
|
||||
?>
|
||||
|
||||
<section class="container py-5">
|
||||
<?php if (!empty($alertMessage)): ?>
|
||||
<div class="alert alert-warning" role="alert">
|
||||
<?php echo $alertMessage; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="row">
|
||||
<!-- Left Sidebar: Profile Picture and Controls -->
|
||||
<div class="col-lg-4">
|
||||
<div class="card mb-4">
|
||||
<div class="card-body bg-body-secondary text-center">
|
||||
<img src="<?php echo htmlspecialchars($userData['img'] ?: 'default_profile.png'); ?>"
|
||||
alt="avatar"
|
||||
class="rounded-circle img-fluid" style="width: 150px;">
|
||||
<!-- Remove username from here -->
|
||||
<button type="button" class="btn btn-sm btn-secondary mb-2"
|
||||
<?php echo ($editingDisabled) ? 'disabled' : ''; ?>
|
||||
data-bs-toggle="modal" data-bs-target="#profilePictureModal">
|
||||
Change Picture
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<!-- List group for username, email, name, and password -->
|
||||
<div class="list-group mb-4">
|
||||
<div class="list-group-item d-flex justify-content-between align-items-center">
|
||||
<span><?php echo $locale['username']; ?>: <?php echo htmlspecialchars($userData['username']); ?></span>
|
||||
<button type="button" class="btn btn-sm btn-secondary"
|
||||
<?php echo ($editingDisabled) ? 'disabled' : ''; ?>
|
||||
data-bs-toggle="modal" data-bs-target="#usernameModal">
|
||||
Change
|
||||
</button>
|
||||
</div>
|
||||
<div class="list-group-item d-flex justify-content-between align-items-center">
|
||||
<span><?php echo $locale['email']; ?>: <?php echo htmlspecialchars($userData['email']); ?></span>
|
||||
<div>
|
||||
<button type="button" class="btn btn-sm btn-secondary me-1"
|
||||
<?php echo ($editingDisabled) ? 'disabled' : ''; ?>
|
||||
data-bs-toggle="modal" data-bs-target="#emailModal">
|
||||
Change
|
||||
</button>
|
||||
<?php if (!$userData['emailVerified']): ?>
|
||||
<button type="button" class="btn btn-sm btn-primary"
|
||||
data-bs-toggle="modal" data-bs-target="#verifyEmailModal">
|
||||
Verify
|
||||
</button>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="list-group-item d-flex justify-content-between align-items-center">
|
||||
<span><?php echo $locale['name']; ?>: <?php echo htmlspecialchars($userData['firstName'] . ' ' . $userData['lastName']); ?></span>
|
||||
<button type="button" class="btn btn-sm btn-secondary"
|
||||
<?php echo ($editingDisabled) ? 'disabled' : ''; ?>
|
||||
data-bs-toggle="modal" data-bs-target="#nameModal">
|
||||
Change Name
|
||||
</button>
|
||||
</div>
|
||||
<div class="list-group-item d-flex justify-content-between align-items-center">
|
||||
<span>Password</span>
|
||||
<button type="button" class="btn btn-sm btn-secondary"
|
||||
<?php echo ($editingDisabled) ? 'disabled' : ''; ?>
|
||||
data-bs-toggle="modal" data-bs-target="#passwordModal">
|
||||
Change
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Right Content: Additional Options -->
|
||||
<div class="col-lg-8">
|
||||
<div class="card mb-4">
|
||||
<div class="card-body bg-body-secondary">
|
||||
<h5>Additional Features</h5>
|
||||
<p>Followed DJs and recent ratings will appear here once implemented.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- Modals -->
|
||||
<!-- 1. Profile Picture Modal -->
|
||||
<div class="modal fade" id="profilePictureModal" tabindex="-1" aria-labelledby="profilePictureModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog">
|
||||
<form action="update_profile_picture.php" method="post" enctype="multipart/form-data">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="profilePictureModalLabel">Change Profile Picture</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<!-- CSRF token can be added here as hidden input if needed -->
|
||||
<div class="mb-3">
|
||||
<label for="profilePicture" class="form-label">Select new profile picture</label>
|
||||
<input type="file" class="form-control" id="profilePicture" name="profile_picture" accept="image/*" required>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Cancel</button>
|
||||
<button type="submit" class="btn btn-primary">Update Picture</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 2. Username Modal -->
|
||||
<div class="modal fade" id="usernameModal" tabindex="-1" aria-labelledby="usernameModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog">
|
||||
<form action="update_username.php" method="post">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="usernameModalLabel">Change Username</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="mb-3">
|
||||
<label for="newUsername" class="form-label">New Username</label>
|
||||
<input type="text" class="form-control" id="newUsername" name="new_username" required>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Cancel</button>
|
||||
<button type="submit" class="btn btn-primary">Update Username</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 3. Email Modal -->
|
||||
<div class="modal fade" id="emailModal" tabindex="-1" aria-labelledby="emailModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog">
|
||||
<form action="update_email.php" method="post">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="emailModalLabel">Change Email</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="mb-3">
|
||||
<label for="newEmail" class="form-label">New Email Address</label>
|
||||
<input type="email" class="form-control" id="newEmail" name="new_email" required>
|
||||
</div>
|
||||
<p class="text-muted">Note: Changing your email will require you to verify the new address.</p>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Cancel</button>
|
||||
<button type="submit" class="btn btn-primary">Update Email</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 4. Verify Email Modal -->
|
||||
<div class="modal fade" id="verifyEmailModal" tabindex="-1" aria-labelledby="verifyEmailModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog">
|
||||
<form action="verify_email.php" method="post">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="verifyEmailModalLabel">Verify Your Email</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<p>An email with a verification code has been sent to your address. Please enter the code below. (Or click the link in the email to auto-verify.)</p>
|
||||
<div class="mb-3">
|
||||
<label for="verificationCode" class="form-label">Verification Code</label>
|
||||
<input type="text" class="form-control" id="verificationCode" name="verification_code" required>
|
||||
</div>
|
||||
<p class="small text-muted">You can only request a new code once every 15 minutes.</p>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Cancel</button>
|
||||
<button type="submit" class="btn btn-primary">Verify Email</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 5. Name Modal (First & Last Name) -->
|
||||
<div class="modal fade" id="nameModal" tabindex="-1" aria-labelledby="nameModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog">
|
||||
<form action="update_name.php" method="post">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="nameModalLabel">Change Your Name</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="mb-3">
|
||||
<label for="firstName" class="form-label">First Name</label>
|
||||
<input type="text" class="form-control" id="firstName" name="first_name" value="<?php echo htmlspecialchars($userData['firstName']); ?>" required>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="lastName" class="form-label">Last Name</label>
|
||||
<input type="text" class="form-control" id="lastName" name="last_name" value="<?php echo htmlspecialchars($userData['lastName']); ?>" required>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Cancel</button>
|
||||
<button type="submit" class="btn btn-primary">Update Name</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 6. Password Modal -->
|
||||
<div class="modal fade" id="passwordModal" tabindex="-1" aria-labelledby="passwordModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog">
|
||||
<form action="update_password.php" method="post">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="passwordModalLabel">Change Password</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="mb-3">
|
||||
<label for="currentPassword" class="form-label">Current Password</label>
|
||||
<input type="password" class="form-control" id="currentPassword" name="current_password" required>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="newPassword" class="form-label">New Password</label>
|
||||
<input type="password" class="form-control" id="newPassword" name="new_password" required>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="confirmPassword" class="form-label">Confirm New Password</label>
|
||||
<input type="password" class="form-control" id="confirmPassword" name="confirm_password" required>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Cancel</button>
|
||||
<button type="submit" class="btn btn-primary">Change Password</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php require_once 'includes/footer.php'; ?>
|
Loading…
Add table
Add a link
Reference in a new issue