35418-vm/index.php
2025-11-02 14:43:46 +00:00

84 lines
3.6 KiB
PHP

<?php
require_once 'includes/header.php';
// If user is logged in, redirect to dashboard
if (isset($_SESSION['user_id'])) {
header('Location: dashboard.php');
exit();
}
// Run setup on first visit to ensure db and table exist, but hide output
ob_start();
require_once 'db/config.php';
include_once 'db/setup.php';
ob_end_clean();
?>
<div class="text-center hero-section">
<h1 class="display-3 fw-bold">Level Up Your IT Skills</h1>
<p class="lead col-lg-6 mx-auto">Join quests, conquer challenges, and rise through the ranks. Your journey to becoming an IT master starts now.</p>
</div>
<div class="row justify-content-center g-5 mt-4">
<!-- Login Card -->
<div class="col-lg-5" id="login">
<div class="card bg-surface text-light p-4">
<div class="card-body">
<h2 class="card-title text-center mb-4">Player Login</h2>
<?php if(isset($_GET['login_error'])): ?>
<div class="alert alert-danger">Invalid username or password.</div>
<?php endif; ?>
<form action="login.php" method="POST">
<div class="mb-3">
<label for="login-username" class="form-label">Username</label>
<input type="text" class="form-control" id="login-username" name="username" required>
</div>
<div class="mb-3">
<label for="login-password" class="form-label">Password</label>
<input type="password" class="form-control" id="login-password" name="password" required>
</div>
<div class="d-grid">
<button type="submit" class="btn btn-primary btn-lg">Enter Dungeon</button>
</div>
</form>
</div>
</div>
</div>
<!-- Registration Card -->
<div class="col-lg-5" id="register">
<div class="card bg-surface text-light p-4">
<div class="card-body">
<h2 class="card-title text-center mb-4">New Player</h2>
<?php if(isset($_GET['reg_error'])): ?>
<div class="alert alert-danger"><?php echo htmlspecialchars($_GET['reg_error']); ?></div>
<?php endif; ?>
<?php if(isset($_GET['reg_success'])): ?>
<div class="alert alert-success">Registration successful! Please log in.</div>
<?php endif; ?>
<form action="register.php" method="POST">
<div class="mb-3">
<label for="reg-username" class="form-label">Username</label>
<input type="text" class="form-control" id="reg-username" name="username" required>
</div>
<div class="mb-3">
<label for="reg-password" class="form-label">Password</label>
<input type="password" class="form-control" id="reg-password" name="password" required>
</div>
<div class="mb-3">
<label for="reg-confirm-password" class="form-label">Confirm Password</label>
<input type="password" class="form-control" id="reg-confirm-password" name="confirm_password" required>
</div>
<div class="d-grid">
<button type="submit" class="btn btn-secondary btn-lg">Join the Guild</button>
</div>
</form>
</div>
</div>
</div>
</div>
<?php
require_once 'includes/footer.php';
?>