menu

student-portal

أستلر Learning Management System

// Redirect to dashboard if already logged in if (lms_is_logged_in()) { header("Location: " . url('/dashboard')); exit; } $error_msg = ''; $active_tab = 'login'; // 'login' or 'register' if ($_SERVER['REQUEST_METHOD'] === 'POST') { // CSRF Check $token = $_POST['csrf_token'] ?? ''; if (!csrf_verify($token)) { $error_msg = "Security token mismatch. Please try again."; } else { $action = $_POST['action'] ?? ''; $redirect = $_GET['redirect'] ?? $_POST['redirect'] ?? ''; $target = '/dashboard'; if ($redirect === 'checkout') { $target = '/dashboard?checkout=true'; } if ($action === 'login') { $email = $_POST['email'] ?? ''; $password = $_POST['password'] ?? ''; if (lms_login($email, $password)) { header("Location: " . url($target)); exit; } else { $error_msg = __('wrong-credentials'); } } elseif ($action === 'register') { $active_tab = 'register'; $name = $_POST['name'] ?? ''; $email = $_POST['email'] ?? ''; $password = $_POST['password'] ?? ''; try { if (lms_register($name, $email, $password)) { // Log the user in after registration lms_login($email, $password); header("Location: " . url($target)); exit; } } catch (Exception $e) { $error_msg = $e->getMessage(); } } } } // UI Meta Setup $title = 'student-portal'; $hide_header = false; $hide_footer = false; include __DIR__ . '/../../../includes/layouts/header.php'; ?>

student-portal

أستلر Learning Management System