Sindbad~EG File Manager
<?php
require_once 'includes/functions.php';
// Redirect if already logged in
if (isLoggedIn()) {
header('Location: ' . BASE_URL . 'dashboard.php');
exit();
}
$error = '';
$success = '';
$db = new CopMadinaDB();
$conn = $db->getConnection();
// Get areas, districts, and assemblies for dropdown
$areas = executeQuery("SELECT * FROM areas WHERE status = 'active' ORDER BY name")->fetchAll();
$districts = [];
$assemblies = [];
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$firstName = sanitizeInput($_POST['first_name'] ?? '');
$lastName = sanitizeInput($_POST['last_name'] ?? '');
$email = sanitizeInput($_POST['email'] ?? '');
$phone = sanitizeInput($_POST['phone'] ?? '');
$password = $_POST['password'] ?? '';
$confirmPassword = $_POST['confirm_password'] ?? '';
$areaId = $_POST['area_id'] ?? null;
$districtId = $_POST['district_id'] ?? null;
$assemblyId = $_POST['assembly_id'] ?? null;
// Validation
if (empty($firstName) || empty($lastName) || empty($email) || empty($password)) {
$error = 'Please fill in all required fields.';
} elseif (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
$error = 'Please enter a valid email address.';
} elseif (strlen($password) < PASSWORD_MIN_LENGTH) {
$error = 'Password must be at least ' . PASSWORD_MIN_LENGTH . ' characters long.';
} elseif ($password !== $confirmPassword) {
$error = 'Passwords do not match.';
} else {
// Check if email already exists
$stmt = $conn->prepare("SELECT id FROM users WHERE email = ?");
$stmt->execute([$email]);
if ($stmt->fetch()) {
$error = 'An account with this email address already exists.';
} else {
try {
$hashedPassword = password_hash($password, PASSWORD_DEFAULT);
$stmt = $conn->prepare("INSERT INTO users (first_name, last_name, email, phone, password, role, area_id, district_id, assembly_id, status)
VALUES (?, ?, ?, ?, ?, 'member', ?, ?, ?, 'active')");
$stmt->execute([$firstName, $lastName, $email, $phone, $hashedPassword, $areaId, $districtId, $assemblyId]);
$userId = $conn->lastInsertId();
// Log audit
logAudit('register', 'users', $userId);
// Add welcome notification
addNotification($userId, 'Welcome to COP Madina Conference Management',
'Your account has been created successfully. You can now register for events and access member features.',
'success');
$success = 'Account created successfully! You can now login with your credentials.';
} catch (Exception $e) {
$error = 'Registration failed. Please try again.';
error_log("Registration error: " . $e->getMessage());
}
}
}
}
// Get districts for selected area
if (isset($_GET['area_id'])) {
$areaId = $_GET['area_id'];
$stmt = $conn->prepare("SELECT * FROM districts WHERE area_id = ? AND status = 'active' ORDER BY name");
$stmt->execute([$areaId]);
$districts = $stmt->fetchAll();
header('Content-Type: application/json');
echo json_encode($districts);
exit();
}
// Get assemblies for selected district
if (isset($_GET['district_id'])) {
$districtId = $_GET['district_id'];
$stmt = $conn->prepare("SELECT * FROM assemblies WHERE district_id = ? AND status = 'active' ORDER BY name");
$stmt->execute([$districtId]);
$assemblies = $stmt->fetchAll();
header('Content-Type: application/json');
echo json_encode($assemblies);
exit();
}
$settings = getSettings();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Member Registration - COP Madina Conference Management</title>
<script src="https://cdn.tailwindcss.com"></script>
<script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css" rel="stylesheet">
<script>
tailwind.config = {
theme: {
extend: {
colors: {
primary: {
50: '#eff6ff',
100: '#dbeafe',
500: '#3b82f6',
600: '#2563eb',
700: '#1d4ed8',
800: '#1e40af',
900: '#1e3a8a'
}
}
}
}
}
</script>
<style>
.gradient-bg {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}
</style>
</head>
<body class="bg-gray-50 min-h-screen flex items-center justify-center py-12 px-4 sm:px-6 lg:px-8">
<div id="app" class="max-w-md w-full space-y-8">
<!-- Header -->
<div class="text-center">
<a href="<?php echo BASE_URL; ?>" class="inline-block">
<img src="<?php echo BASE_URL; ?>assets/images/logo.png" alt="COP Madina" class="mx-auto h-16 w-16 rounded-full">
</a>
<h2 class="mt-6 text-3xl font-extrabold text-gray-900">Create Member Account</h2>
<p class="mt-2 text-sm text-gray-600">
Join our community to register for events and access member features
</p>
<p class="mt-2 text-sm text-gray-600">
Already have an account?
<a href="<?php echo BASE_URL; ?>login.php" class="font-medium text-primary-600 hover:text-primary-500">
Sign in here
</a>
</p>
</div>
<!-- Registration Form -->
<form class="mt-8 space-y-6" method="POST">
<div class="bg-white shadow-lg rounded-lg p-8">
<?php if ($error): ?>
<div class="mb-4 bg-red-50 border border-red-200 text-red-700 px-4 py-3 rounded-lg">
<div class="flex items-center">
<i class="fas fa-exclamation-circle mr-2"></i>
<?php echo htmlspecialchars($error); ?>
</div>
</div>
<?php endif; ?>
<?php if ($success): ?>
<div class="mb-4 bg-green-50 border border-green-200 text-green-700 px-4 py-3 rounded-lg">
<div class="flex items-center">
<i class="fas fa-check-circle mr-2"></i>
<?php echo htmlspecialchars($success); ?>
</div>
<div class="mt-4">
<a href="<?php echo BASE_URL; ?>login.php"
class="bg-green-600 text-white px-4 py-2 rounded-lg hover:bg-green-700 transition-colors">
Login Now
</a>
</div>
</div>
<?php endif; ?>
<div class="space-y-4">
<!-- Personal Information -->
<div class="grid grid-cols-2 gap-4">
<div>
<label for="first_name" class="block text-sm font-medium text-gray-700 mb-2">
First Name <span class="text-red-500">*</span>
</label>
<input id="first_name" name="first_name" type="text" required
class="block w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-primary-500 focus:border-primary-500"
value="<?php echo htmlspecialchars($_POST['first_name'] ?? ''); ?>">
</div>
<div>
<label for="last_name" class="block text-sm font-medium text-gray-700 mb-2">
Last Name <span class="text-red-500">*</span>
</label>
<input id="last_name" name="last_name" type="text" required
class="block w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-primary-500 focus:border-primary-500"
value="<?php echo htmlspecialchars($_POST['last_name'] ?? ''); ?>">
</div>
</div>
<div>
<label for="email" class="block text-sm font-medium text-gray-700 mb-2">
Email Address <span class="text-red-500">*</span>
</label>
<input id="email" name="email" type="email" required
class="block w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-primary-500 focus:border-primary-500"
value="<?php echo htmlspecialchars($_POST['email'] ?? ''); ?>">
</div>
<div>
<label for="phone" class="block text-sm font-medium text-gray-700 mb-2">
Phone Number
</label>
<input id="phone" name="phone" type="tel"
class="block w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-primary-500 focus:border-primary-500"
value="<?php echo htmlspecialchars($_POST['phone'] ?? ''); ?>">
</div>
<!-- Church Affiliation -->
<div class="border-t border-gray-200 pt-4">
<h3 class="text-lg font-medium text-gray-900 mb-4">Church Affiliation (Optional)</h3>
<div>
<label for="area_id" class="block text-sm font-medium text-gray-700 mb-2">
Area
</label>
<select id="area_id" name="area_id" @change="loadDistricts"
class="block w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-primary-500 focus:border-primary-500">
<option value="">Select Area</option>
<?php foreach ($areas as $area): ?>
<option value="<?php echo $area['id']; ?>"
<?php echo ($_POST['area_id'] ?? '') == $area['id'] ? 'selected' : ''; ?>>
<?php echo htmlspecialchars($area['name']); ?>
</option>
<?php endforeach; ?>
</select>
</div>
<div class="mt-4">
<label for="district_id" class="block text-sm font-medium text-gray-700 mb-2">
District
</label>
<select id="district_id" name="district_id" @change="loadAssemblies" :disabled="!selectedArea"
class="block w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-primary-500 focus:border-primary-500 disabled:bg-gray-100">
<option value="">Select District</option>
<option v-for="district in districts" :key="district.id" :value="district.id">
{{ district.name }}
</option>
</select>
</div>
<div class="mt-4">
<label for="assembly_id" class="block text-sm font-medium text-gray-700 mb-2">
Assembly
</label>
<select id="assembly_id" name="assembly_id" :disabled="!selectedDistrict"
class="block w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-primary-500 focus:border-primary-500 disabled:bg-gray-100">
<option value="">Select Assembly</option>
<option v-for="assembly in assemblies" :key="assembly.id" :value="assembly.id">
{{ assembly.name }}
</option>
</select>
</div>
</div>
<!-- Password -->
<div class="border-t border-gray-200 pt-4">
<div class="grid grid-cols-2 gap-4">
<div>
<label for="password" class="block text-sm font-medium text-gray-700 mb-2">
Password <span class="text-red-500">*</span>
</label>
<input id="password" name="password" type="password" required
class="block w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-primary-500 focus:border-primary-500">
<p class="text-xs text-gray-500 mt-1">Minimum <?php echo PASSWORD_MIN_LENGTH; ?> characters</p>
</div>
<div>
<label for="confirm_password" class="block text-sm font-medium text-gray-700 mb-2">
Confirm Password <span class="text-red-500">*</span>
</label>
<input id="confirm_password" name="confirm_password" type="password" required
class="block w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-primary-500 focus:border-primary-500">
</div>
</div>
</div>
<!-- Terms and Conditions -->
<div class="flex items-start">
<input id="terms" name="terms" type="checkbox" required
class="h-4 w-4 text-primary-600 focus:ring-primary-500 border-gray-300 rounded mt-1">
<label for="terms" class="ml-2 block text-sm text-gray-700">
I agree to the <a href="#" class="text-primary-600 hover:text-primary-500">Terms of Service</a>
and <a href="#" class="text-primary-600 hover:text-primary-500">Privacy Policy</a>
</label>
</div>
</div>
<div class="mt-6">
<button type="submit"
class="group relative w-full flex justify-center py-3 px-4 border border-transparent text-sm font-medium rounded-lg text-white gradient-bg hover:opacity-90 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-primary-500 transition-all duration-200">
<span class="absolute left-0 inset-y-0 flex items-center pl-3">
<i class="fas fa-user-plus text-white"></i>
</span>
Create Account
</button>
</div>
</div>
</form>
<!-- Footer Links -->
<div class="text-center">
<div class="flex justify-center space-x-6 text-sm">
<a href="<?php echo BASE_URL; ?>" class="text-gray-600 hover:text-gray-900">
<i class="fas fa-home mr-1"></i>Home
</a>
<a href="<?php echo BASE_URL; ?>contact.php" class="text-gray-600 hover:text-gray-900">
<i class="fas fa-envelope mr-1"></i>Contact
</a>
<a href="<?php echo BASE_URL; ?>help.php" class="text-gray-600 hover:text-gray-900">
<i class="fas fa-question-circle mr-1"></i>Help
</a>
</div>
<p class="mt-4 text-xs text-gray-500">
© <?php echo date('Y'); ?> The Church of Pentecost - Madina Area. All rights reserved.
</p>
</div>
</div>
<script>
const { createApp } = Vue;
createApp({
data() {
return {
selectedArea: null,
selectedDistrict: null,
districts: [],
assemblies: []
}
},
methods: {
async loadDistricts() {
const areaSelect = document.getElementById('area_id');
this.selectedArea = areaSelect.value;
this.selectedDistrict = null;
this.districts = [];
this.assemblies = [];
// Reset district and assembly selects
document.getElementById('district_id').value = '';
document.getElementById('assembly_id').value = '';
if (this.selectedArea) {
try {
const response = await fetch(`?area_id=${this.selectedArea}`);
this.districts = await response.json();
} catch (error) {
console.error('Error loading districts:', error);
}
}
},
async loadAssemblies() {
const districtSelect = document.getElementById('district_id');
this.selectedDistrict = districtSelect.value;
this.assemblies = [];
// Reset assembly select
document.getElementById('assembly_id').value = '';
if (this.selectedDistrict) {
try {
const response = await fetch(`?district_id=${this.selectedDistrict}`);
this.assemblies = await response.json();
} catch (error) {
console.error('Error loading assemblies:', error);
}
}
}
},
mounted() {
// Auto-focus on first name field
document.getElementById('first_name').focus();
}
}).mount('#app');
</script>
</body>
</html>
Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists