prepare("INSERT INTO users (id, supabase_uid, student_id, name, email, role) VALUES (?, ?, ?, ?, ?, ?)"); $stmt->execute([$id, $supabase_uid, $student_id, $name, $email, $role]); $_SESSION['user_id'] = $id; $_SESSION['user_role'] = $role; audit_log('User registered', 'users', $id); header('Location: index.php'); exit; } catch (PDOException $e) { if ($e->getCode() == 23000) { $error = 'Student ID or Email already exists.'; } else { $error = 'An error occurred: ' . $e->getMessage(); } } catch (Exception $e) { $error = $e->getMessage(); } } } ?> Registration - Iloilo National High School