HEX
Server: Apache/2.4.46 (Ubuntu)
System: Linux localhost 5.11.0-49-generic #55-Ubuntu SMP Wed Jan 12 17:36:34 UTC 2022 x86_64
User: root (0)
PHP: 7.4.16
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /var/www/html/lab-portal/index.php
<?php include 'header.php' ?>
<style>
/* Background Overlay */
.overlay {
    width: 100%;
    height: 90vh;
    background: rgb(239 74 35 / 39%);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Login Box */
.login-box {
    width: 380px;
    background: #fff;
    padding: 25px;
    border-radius: 10px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.2);
}

/* Header */
.login-header {
    text-align: center;
    padding: 15px 0;
    background: #e8ecef;
    border-radius: 8px;
    margin-bottom: 25px;
}

.login-header .icon {
    font-size: 25px;
    display: block;
}

.login-header h2 {
    margin: 5px 0 0;
    font-size: 20px;
    font-weight: 600;
}

/* Input Group */
.input-group {
    display: flex;
    align-items: center;
    background: #e9f0ff;
    padding: 12px;
    border-radius: 6px;
    margin-bottom: 15px;
    border: 1px solid #d5ddf0;
}

.input-group input {
    width: 100%;
    border: none;
    background: transparent;
    font-size: 16px;
    padding-left: 10px;
    outline: none;
}

.input-icon {
    font-size: 18px;
}

.toggle-eye {
    cursor: pointer;
    font-size: 18px;
    padding-left: 8px;
}

/* Remember Me */
.remember {
    display: flex;
    align-items: center;
    margin-bottom: 20px;
}

.remember input {
    width: 18px;
    height: 18px;
    margin-right: 8px;
}

.remember label {
    font-size: 15px;
    color: #333;
}

/* Login Button */
.login-btn {
    width: 100%;
    background: #ef4a23;
    color: #fff;
    padding: 15px 0;
    border-radius: 6px;
    font-size: 18px;
    border: none;
    cursor: pointer;
    font-weight: 600;
}

.login-btn:hover {
    background: #196775;
}

.password-group {
    position: relative;
}

.password-group input {
    width: 100%;
    padding-right: 40px;
    /* space for eye icon */
}

.password-group .toggle-eye {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    cursor: pointer;
    font-size: 18px;
}
</style>
<main>
    <div class="overlay">
        <div class="login-box">

            <div class="login-header">
                <h2>Sign in</h2>
            </div>

            <form id="loginForm">
                <!-- Username -->
                <div class="input-group">
                    <input type="text" id="email" placeholder="Enter email" />
                </div>

                <!-- Password -->
                <div class="input-group password-group">
                    <input type="password" id="password" placeholder="••••••••" />
                    <span class="toggle-eye" onclick="togglePassword()">👁</span>
                </div>

                <!-- Remember Me -->
                <div class="remember">
                    <input type="checkbox" id="remember">
                    <label for="remember">Remember me</label>
                </div>

                <!-- Login Button -->
                <button type="submit" class="login-btn">Log in</button>

                <!-- Message -->
                <p id="msg"></p>
            </form>

            <script>
            function togglePassword() {
                const pass = document.getElementById("password");
                pass.type = pass.type === "password" ? "text" : "password";
            }

            // FORM SUBMIT
            document.getElementById("loginForm").addEventListener("submit", function(e) {
                e.preventDefault();

                let email = document.getElementById("email").value;
                let password = document.getElementById("password").value;
                let msg = document.getElementById("msg");

                fetch("login.php", {
                        method: "POST",
                        headers: {
                            "Content-Type": "application/json"
                        },
                        body: JSON.stringify({
                            email,
                            password
                        })
                    })
                    .then(res => res.json())
                    .then(data => {
                        if (data.success) {
                            msg.style.color = "green";
                            msg.innerText = data.message;

                            setTimeout(() => {
                                window.location.href = data.redirect;
                            }, 1200);
                        } else {
                            msg.style.color = "red";
                            msg.innerText = data.message;
                        }
                    });
            });
            </script>


        </div>
    </div>

    <script>
    function togglePassword() {
        const field = document.getElementById("password");
        field.type = field.type === "password" ? "text" : "password";
    }
    </script>
</main>


<?php include "footer.php"; ?>