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"; ?>