prepare("SELECT id FROM users WHERE email = ?"); $stmt->execute([$email]); if ($stmt->fetch()) { $errors[] = 'Email address is already registered'; } } catch (PDOException $e) { $errors[] = "Database error: " . $e->getMessage(); } } if (empty($errors)) { try { $hashed_password = password_hash($password, PASSWORD_DEFAULT); $pdo = db(); $stmt = $pdo->prepare( "INSERT INTO users (email, password, role, name, address, contact_person, registration_number, areas_served) VALUES (?, ?, 'ngo', ?, ?, ?, ?, ?)" ); $stmt->execute([$email, $hashed_password, $name, $address, $contact_person, $registration_number, $areas_served]); // Redirect to login page on success header("Location: login.php?registration=success"); exit; } catch (PDOException $e) { $errors[] = "Database error on registration: " . $e->getMessage(); } } } ?>

NGO Registration