JezK
Edit File: signup.php
<?php // signup.php $pageTitle = 'Create Student Account'; $noIndex = true; require_once 'includes/db.php'; require_once 'includes/auth.php'; // Redirect if already logged in if (isLoggedIn()) { if ($_SESSION['user_role'] === 'admin') { header("Location: admin/dashboard.php"); } else { header("Location: student/dashboard.php"); } exit; } // Check if there's a referral code in cookies $cookie_ref_code = isset($_COOKIE['referred_by']) ? trim($_COOKIE['referred_by']) : ''; $error = ''; if ($_SERVER['REQUEST_METHOD'] === 'POST') { $name = trim($_POST['name']); $email = trim($_POST['email']); $password = $_POST['password']; $ref_code = trim($_POST['referral_code']); if (empty($name) || empty($email) || empty($password)) { $error = 'Please fill in all required fields.'; } elseif (strlen($password) < 6) { $error = 'Password must be at least 6 characters.'; } else { $reg = registerUser($name, $email, $password, $ref_code); if ($reg['success']) { $_SESSION['user_id'] = $reg['user_id']; $_SESSION['user_role'] = $reg['role']; $_SESSION['user_name'] = $reg['name']; $_SESSION['user_email'] = $email; // Clear referral cookie now that they registered if (isset($_COOKIE['referred_by'])) { setcookie('referred_by', '', time() - 3600, '/'); } // Send Welcome Email try { require_once 'includes/mail_helper.php'; $subject = "Welcome to Northstar Union!"; $body = ' <h3 style="color: #fff; font-family: \'Outfit\', sans-serif; font-size: 1.5rem; margin-top: 0;">Welcome to the Union</h3> <p>Dear <strong>' . htmlspecialchars($name) . '</strong>,</p> <p>Thank you for registering an account with Northstar Union. We are excited to have you join our community of learners and professionals.</p> <p>Get started by exploring our courses, booking cohort sessions, and customizing your profile.</p> <p style="text-align: center; margin: 35px 0;"> <a href="https://www.northstarunion.in/student/dashboard.php" style="background: #f2a900; color: #0b0c10; padding: 12px 28px; border-radius: 8px; text-decoration: none; font-weight: bold; font-size: 0.95rem; display: inline-block; box-shadow: 0 4px 15px rgba(242, 169, 0, 0.3);">Go to My Dashboard</a> </p> '; sendEmail($email, $name, $subject, $body); } catch (Exception $mailEx) { error_log("Failed to send welcome email: " . $mailEx->getMessage()); } // Redirect — new users go through profile setup first if (isset($_SESSION['redirect_after_login'])) { $target = $_SESSION['redirect_after_login']; unset($_SESSION['redirect_after_login']); header("Location: $target"); } else { header("Location: profile-setup.php?step=1"); } exit; } else { $error = $reg['message']; } } } include 'includes/header.php'; ?> <main style="min-height: 85vh; display: flex; align-items: center; justify-content: center; padding: 4rem 1rem; position: relative;"> <div style="position: absolute; top: 0; left: 0; width: 100%; height: 100%; overflow: hidden; z-index: -1;"> <div style="position: absolute; width: 300px; height: 300px; border-radius: 50%; background: radial-gradient(circle, rgba(242,169,0,0.15) 0%, transparent 70%); top: 15%; right: 15%; filter: blur(50px);"> </div> <div style="position: absolute; width: 400px; height: 400px; border-radius: 50%; background: radial-gradient(circle, rgba(242,169,0,0.1) 0%, transparent 70%); bottom: 15%; left: 15%; filter: blur(60px);"> </div> </div> <div class="glass-card" style="width: 100%; max-width: 440px; padding: 2.5rem; height: auto;"> <div style="text-align: center; margin-bottom: 2rem;"> <span style="font-size: 0.8rem; text-transform: uppercase; color: var(--accent-gold); letter-spacing: 2px; font-weight: 700; display: block; margin-bottom: 0.5rem;">Join the Union</span> <h2 style="font-size: 2rem; color: #fff; font-family: var(--font-primary);">Create Account</h2> <p style="color: var(--text-secondary); font-size: 0.88rem; margin-top: 0.5rem;">Build your future with industry-relevant skills.</p> </div> <?php if (!empty($error)): ?> <div style="background: rgba(255, 82, 82, 0.1); border: 1px solid rgba(255, 82, 82, 0.2); color: #ff5252; padding: 0.8rem 1rem; border-radius: 8px; font-size: 0.88rem; margin-bottom: 1.5rem; text-align: center;"> <?php echo htmlspecialchars($error); ?> </div> <?php endif; ?> <form method="POST" action="signup.php" style="display: grid; gap: 1.2rem;"> <div> <label style="display: block; font-size: 0.8rem; text-transform: uppercase; color: var(--text-secondary); margin-bottom: 0.4rem; font-weight: 600;">Full Name *</label> <input type="text" name="name" required placeholder="John Doe" value="<?php echo isset($_POST['name']) ? htmlspecialchars($_POST['name']) : ''; ?>" style="width: 100%; background: rgba(255, 255, 255, 0.03); border: 1px solid var(--border-color); border-radius: 8px; padding: 0.85rem; color: #fff; font-family: inherit; font-size: 0.95rem; outline: none; transition: var(--transition-fast);"> </div> <div> <label style="display: block; font-size: 0.8rem; text-transform: uppercase; color: var(--text-secondary); margin-bottom: 0.4rem; font-weight: 600;">Email Address *</label> <input type="email" name="email" required placeholder="name@example.com" value="<?php echo isset($_POST['email']) ? htmlspecialchars($_POST['email']) : ''; ?>" style="width: 100%; background: rgba(255, 255, 255, 0.03); border: 1px solid var(--border-color); border-radius: 8px; padding: 0.85rem; color: #fff; font-family: inherit; font-size: 0.95rem; outline: none; transition: var(--transition-fast);"> </div> <div> <label style="display: block; font-size: 0.8rem; text-transform: uppercase; color: var(--text-secondary); margin-bottom: 0.4rem; font-weight: 600;">Password * (min 6 chars)</label> <input type="password" name="password" required placeholder="••••••••" style="width: 100%; background: rgba(255, 255, 255, 0.03); border: 1px solid var(--border-color); border-radius: 8px; padding: 0.85rem; color: #fff; font-family: inherit; font-size: 0.95rem; outline: none; transition: var(--transition-fast);"> </div> <div> <label style="display: block; font-size: 0.8rem; text-transform: uppercase; color: var(--text-secondary); margin-bottom: 0.4rem; font-weight: 600;">Referral Code (Optional)</label> <input type="text" name="referral_code" placeholder="e.g. MARC4520" value="<?php echo isset($_POST['referral_code']) ? htmlspecialchars($_POST['referral_code']) : htmlspecialchars($cookie_ref_code); ?>" style="width: 100%; background: rgba(255, 255, 255, 0.03); border: 1px solid var(--border-color); border-radius: 8px; padding: 0.85rem; color: #fff; font-family: inherit; font-size: 0.95rem; outline: none; transition: var(--transition-fast);"> <small style="color: var(--text-muted); font-size: 0.75rem; margin-top: 0.3rem; display: block;">If you were referred by a friend, enter their code here.</small> </div> <button type="submit" class="btn-primary" style="justify-content: center; padding: 0.95rem; font-weight: 700; width: 100%; margin-top: 0.5rem; font-size: 0.95rem;"> Register ➔ </button> </form> <div style="text-align: center; margin-top: 2rem; font-size: 0.88rem; color: var(--text-secondary);"> Already have an account? <a href="login.php" style="color: var(--accent-gold); text-decoration: none; font-weight: 600;">Sign In</a> </div> </div> </main> <style> input:focus { border-color: var(--accent-gold) !important; background: rgba(255, 255, 255, 0.05) !important; box-shadow: 0 0 10px rgba(242, 169, 0, 0.1); } </style> <?php include 'includes/footer.php'; ?>