| Server IP : 198.54.126.135 / Your IP : 216.73.216.217 Web Server : Apache System : Linux host11.registrar-servers.com 4.18.0-553.lve.el8.x86_64 #1 SMP Mon May 27 15:27:34 UTC 2024 x86_64 User : linearpo ( 12988) PHP Version : 8.1.34 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home/linearpo/public_html/app/ |
Upload File : |
<?php
// index.php - Login Page
require_once 'config.php';
if (isset($_SESSION['user_id'])) {
header("Location: dashboard.php");
exit();
}
$error = '';
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$username = $conn->real_escape_string($_POST['username']);
$password = $_POST['password'];
$result = $conn->query("SELECT * FROM users WHERE username = '$username' AND status = 'active'");
if ($result->num_rows > 0) {
$user = $result->fetch_assoc();
if (password_verify($password, $user['password'])) {
$_SESSION['user_id'] = $user['id'];
$_SESSION['username'] = $user['username'];
$_SESSION['full_name'] = $user['full_name'];
$_SESSION['role'] = $user['role'];
header("Location: dashboard.php");
exit();
} else {
$error = 'Invalid password';
}
} else {
$error = 'User not found or inactive';
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>M-Pesa Agent System - Login</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
<link href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.0/font/bootstrap-icons.css" rel="stylesheet">
<style>
body {
background: linear-gradient(135deg, #00a650 0%, #000000 100%);
min-height: 100vh;
display: flex;
align-items: center;
justify-content: center;
}
.login-card {
background: white;
border-radius: 15px;
box-shadow: 0 10px 30px rgba(0,0,0,0.3);
overflow: hidden;
width: 100%;
max-width: 400px;
}
.login-header {
background: #00a650;
color: white;
padding: 30px;
text-align: center;
}
.login-header i {
font-size: 3rem;
margin-bottom: 10px;
}
.login-body {
padding: 40px;
}
.btn-login {
background: #00a650;
border: none;
width: 100%;
padding: 12px;
font-weight: 600;
}
.btn-login:hover {
background: #008f43;
}
.form-floating:focus-within label {
color: #00a650;
}
.form-control:focus {
border-color: #00a650;
box-shadow: 0 0 0 0.25rem rgba(0, 166, 80, 0.25);
}
</style>
</head>
<body>
<div class="login-card">
<div class="login-header">
<i class="bi bi-phone-fill"></i>
<h3>M-Pesa Agent</h3>
<p class="mb-0">Management System</p>
</div>
<div class="login-body">
<?php if ($error): ?>
<div class="alert alert-danger alert-dismissible fade show" role="alert">
<i class="bi bi-exclamation-triangle-fill me-2"></i><?php echo $error; ?>
<button type="button" class="btn-close" data-bs-dismiss="alert"></button>
</div>
<?php endif; ?>
<form method="POST" action="">
<div class="form-floating mb-3">
<input type="text" class="form-control" id="username" name="username" placeholder="Username" required>
<label for="username"><i class="bi bi-person me-2"></i>Username</label>
</div>
<div class="form-floating mb-4">
<input type="password" class="form-control" id="password" name="password" placeholder="Password" required>
<label for="password"><i class="bi bi-lock me-2"></i>Password</label>
</div>
<button type="submit" class="btn btn-primary btn-login">
<i class="bi bi-box-arrow-in-right me-2"></i>Login
</button>
</form>
<div class="text-center mt-3">
<small class="text-muted"></small>
</div>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>