138 lines
7.9 KiB
PHP
138 lines
7.9 KiB
PHP
<?php
|
|
require_once __DIR__ . '/db/config.php';
|
|
require_once __DIR__ . '/mail/MailService.php';
|
|
|
|
$error = '';
|
|
$success = '';
|
|
|
|
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|
$full_name = trim($_POST['full_name'] ?? '');
|
|
$email = trim($_POST['email'] ?? '');
|
|
$password = $_POST['password'] ?? '';
|
|
$role = $_POST['role'] ?? '';
|
|
$university = trim($_POST['university'] ?? '');
|
|
$graduation_year = (int)($_POST['graduation_year'] ?? 0);
|
|
|
|
// Simple validation
|
|
if (empty($full_name) || empty($email) || empty($password) || empty($role) || empty($university) || empty($graduation_year)) {
|
|
$error = "All fields are required.";
|
|
} elseif (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
|
|
$error = "Invalid email format.";
|
|
} elseif ($graduation_year < 1900 || $graduation_year > 2100) {
|
|
$error = "Invalid graduation year.";
|
|
} else {
|
|
// Check if email already exists
|
|
$stmt = db()->prepare("SELECT id FROM users WHERE email = ?");
|
|
$stmt->execute([$email]);
|
|
if ($stmt->fetch()) {
|
|
$error = "Email already registered.";
|
|
} else {
|
|
// Generate verification code
|
|
$verification_code = bin2hex(random_bytes(16));
|
|
$hashed_password = password_hash($password, PASSWORD_DEFAULT);
|
|
|
|
// Insert user
|
|
$stmt = db()->prepare("INSERT INTO users (full_name, email, password, role, university, graduation_year, verification_code) VALUES (?, ?, ?, ?, ?, ?, ?)");
|
|
try {
|
|
$stmt->execute([$full_name, $email, $hashed_password, $role, $university, $graduation_year, $verification_code]);
|
|
$success = "Registration successful! Please check your email to verify your account.";
|
|
|
|
// Send verification email
|
|
// MailService::sendMail($email, "Verify your account", "Your verification code is: $verification_code", "Your verification code is: $verification_code");
|
|
// For now, we'll just show the success message.
|
|
} catch (PDOException $e) {
|
|
$error = "Database error: " . $e->getMessage();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
$platformName = defined('PLATFORM_NAME') ? PLATFORM_NAME : 'Gatsby';
|
|
?>
|
|
<!doctype html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
<title>Sign Up — <?= htmlspecialchars($platformName) ?></title>
|
|
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet">
|
|
<link rel="stylesheet" href="assets/css/custom.css?v=<?php echo time(); ?>">
|
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
|
|
</head>
|
|
<body style="display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px;">
|
|
|
|
<div class="card" style="width: 100%; max-width: 500px;">
|
|
<div class="logo" style="text-align: center; margin-bottom: 30px;"><?= htmlspecialchars($platformName) ?></div>
|
|
<h2 style="margin-bottom: 10px; text-align: center;">Join the Exclusive Network</h2>
|
|
<p style="text-align: center; color: var(--text-secondary); margin-bottom: 30px; font-size: 14px;">Verify your student or graduate status to get started.</p>
|
|
|
|
<?php if ($error): ?>
|
|
<div style="background: rgba(255, 0, 0, 0.1); border: 1px solid rgba(255, 0, 0, 0.3); color: #ff5555; padding: 12px; border-radius: 8px; margin-bottom: 20px;">
|
|
<?= htmlspecialchars($error) ?>
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
<?php if ($success): ?>
|
|
<div style="background: rgba(0, 255, 0, 0.1); border: 1px solid rgba(0, 255, 0, 0.3); color: #55ff55; padding: 12px; border-radius: 8px; margin-bottom: 20px;">
|
|
<?= htmlspecialchars($success) ?>
|
|
</div>
|
|
<p style="text-align: center;"><a href="login.php" class="btn btn-primary" style="width: 100%;">Go to Log In</a></p>
|
|
<?php else: ?>
|
|
<form method="POST">
|
|
<div style="margin-bottom: 15px;">
|
|
<label style="display: block; margin-bottom: 8px; font-size: 14px; font-weight: 500;">Full Name</label>
|
|
<input type="text" name="full_name" required style="width: 100%; padding: 12px; border-radius: 12px; background: var(--surface-color); border: 1px solid var(--border-color); color: #fff;">
|
|
</div>
|
|
<div style="margin-bottom: 15px;">
|
|
<label style="display: block; margin-bottom: 8px; font-size: 14px; font-weight: 500;">University Email</label>
|
|
<input type="email" name="email" required style="width: 100%; padding: 12px; border-radius: 12px; background: var(--surface-color); border: 1px solid var(--border-color); color: #fff;" placeholder="you@university.ac.uk">
|
|
<span style="font-size: 12px; color: var(--text-secondary); margin-top: 4px; display: block;">Only university/graduate emails accepted.</span>
|
|
</div>
|
|
<div style="display: grid; grid-template-columns: 1fr 1fr; gap: 15px; margin-bottom: 15px;">
|
|
<div>
|
|
<label style="display: block; margin-bottom: 8px; font-size: 14px; font-weight: 500;">University</label>
|
|
<input type="text" name="university" required style="width: 100%; padding: 12px; border-radius: 12px; background: var(--surface-color); border: 1px solid var(--border-color); color: #fff;">
|
|
</div>
|
|
<div>
|
|
<label style="display: block; margin-bottom: 8px; font-size: 14px; font-weight: 500;">Grad Year</label>
|
|
<input type="number" name="graduation_year" required style="width: 100%; padding: 12px; border-radius: 12px; background: var(--surface-color); border: 1px solid var(--border-color); color: #fff;" placeholder="2026">
|
|
</div>
|
|
</div>
|
|
<div style="margin-bottom: 15px;">
|
|
<label style="display: block; margin-bottom: 8px; font-size: 14px; font-weight: 500;">Password</label>
|
|
<input type="password" name="password" required style="width: 100%; padding: 12px; border-radius: 12px; background: var(--surface-color); border: 1px solid var(--border-color); color: #fff;">
|
|
</div>
|
|
<div style="margin-bottom: 25px;">
|
|
<label style="display: block; margin-bottom: 8px; font-size: 14px; font-weight: 500;">I want to be a:</label>
|
|
<div style="display: grid; grid-template-columns: 1fr 1fr; gap: 15px;">
|
|
<label style="display: block; cursor: pointer;">
|
|
<input type="radio" name="role" value="founder" required style="display: none;" class="role-radio">
|
|
<div class="role-box" style="padding: 15px; border: 1px solid var(--border-color); border-radius: 12px; text-align: center; transition: all 0.2s;">
|
|
Founder
|
|
</div>
|
|
</label>
|
|
<label style="display: block; cursor: pointer;">
|
|
<input type="radio" name="role" value="investor" required style="display: none;" class="role-radio">
|
|
<div class="role-box" style="padding: 15px; border: 1px solid var(--border-color); border-radius: 12px; text-align: center; transition: all 0.2s;">
|
|
Investor
|
|
</div>
|
|
</label>
|
|
</div>
|
|
</div>
|
|
<button type="submit" class="btn btn-primary" style="width: 100%; padding: 15px;">Create Account</button>
|
|
<p style="text-align: center; margin-top: 20px; color: var(--text-secondary); font-size: 14px;">Already have an account? <a href="login.php" style="color: var(--accent-blue);">Log In</a></p>
|
|
</form>
|
|
<?php endif; ?>
|
|
</div>
|
|
|
|
<style>
|
|
.role-radio:checked + .role-box {
|
|
background: var(--gradient-primary);
|
|
border-color: transparent;
|
|
color: #fff;
|
|
}
|
|
</style>
|
|
|
|
</body>
|
|
</html>
|