CoolFace
Apppublic

Skullwanderer/cohort-manager

sourceHugging Faceupdated 8mo agoView on Hugging Face
0likes
register.php80 linesDownload Raw Back to root
1```php2<?php3session_start();4// If already logged in, redirect to dashboard5if (isset($_SESSION['loggedin']) && $_SESSION['loggedin'] === true) {6    header("Location: index.php");7    exit;8}9$message = '';10if (isset($_GET['error'])) {11    switch ($_GET['error']) {12        case 'exists':13            $message = 'Username already exists. Please choose another.';14            break;15        case 'mismatch':16            $message = 'Passwords do not match.';17            break;18        case 'missing':19            $message = 'All fields are required.';20            break;21    }22}23 24if (isset($_GET['success'])) {25    switch ($_GET['success']) {26        case 'registered':27            $message = 'Registration successful! You can now log in.';28            break;29    }30}31?>32 33<!DOCTYPE html>34<html lang="en">35<head>36    <meta charset="UTF-8">37    <meta name="viewport" content="width=device-width, initial-scale=1.0">38    <title>Register - Cohort Manager</title>39</head>40<body>41    <h1>Register Account</h1>42    43    <?php if (!empty($message)): ?>44        <div style="color: <?php echo (isset($_GET['success'])) ? 'green' : 'red'; ?>; margin-bottom: 15px;">45            <?php echo htmlspecialchars($message); ?>46        </div>47    <?php endif; ?>48    49    <form method="post" action="process_register.php">50        <div>51            <label for="username">Username:</label><br>52            <input type="text" id="username" name="username" required><br><br>53        </div>54        55        <div>56            <label for="password">Password:</label><br>57            <input type="password" id="password" name="password" required><br><br>58        </div>59        60        <div>61            <label for="confirm_password">Confirm Password:</label><br>62            <input type="password" id="confirm_password" name="confirm_password" required><br><br>63        </div>64        65        <div>66            <label for="role">Role:</label><br>67            <select id="role" name="role" required>68                <option value="">Select Role</option>69                <option value="training_officer">Training Officer</option>70                <option value="coordinator">Coordinator</option>71            </select><br><br>72        </div>73        74        <button type="submit">Register</button>75    </form>76    77    <p><a href="login.php">Already have an account? Login here</a></p>78</body>79</html>80```