PNG IHDR x sBIT|d pHYs + tEXtSoftware www.inkscape.org< ,tEXtComment
<?php
session_start();
require_once "../config.php";
if (!isset($_SESSION['auth'])) {
header("Location: ../login.php");
exit;
}
$user_id = $_SESSION['auth'];
$success = $error = "";
// Fetch user’s email for display
$stmt = $pdo->prepare("SELECT email FROM users WHERE id = ?");
$stmt->execute([$user_id]);
$user = $stmt->fetch();
// Handle password or PIN update
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
if (isset($_POST['new_password']) && !empty($_POST['new_password'])) {
$hashed_pass = password_hash($_POST['new_password'], PASSWORD_BCRYPT);
$update = $pdo->prepare("UPDATE users SET password_hash = ? WHERE id = ?");
$update->execute([$hashed_pass, $user_id]);
$success = "✅ Password updated successfully.";
}
if (isset($_POST['new_pin']) && !empty($_POST['new_pin'])) {
if (strlen($_POST['new_pin']) < 4 || !ctype_digit($_POST['new_pin'])) {
$error = "❌ PIN must be a 4-digit number.";
} else {
$hashed_pin = password_hash($_POST['new_pin'], PASSWORD_BCRYPT);
$update = $pdo->prepare("UPDATE users SET pin_hash = ? WHERE id = ?");
$update->execute([$hashed_pin, $user_id]);
$success = "✅ Transaction PIN updated successfully.";
}
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Security & Privacy</title>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;600&display=swap" rel="stylesheet">
<style>
body {
font-family: 'Inter', sans-serif;
background-color: #f4f6f8;
margin: 0;
}
.header {
background: linear-gradient(90deg, #004080, #0070c0);
color: #fff;
padding: 1rem 1.5rem;
display: flex;
justify-content: space-between;
align-items: center;
position: sticky;
top: 0;
box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}
.header h2 { margin: 0; font-size: 1.3rem; font-weight: 600; }
.header span { cursor: pointer; opacity: 0.9; }
.container {
max-width: 650px;
margin: 40px auto;
background: #fff;
border-radius: 16px;
padding: 35px;
box-shadow: 0 10px 25px rgba(0,0,0,0.08);
}
h3 {
color: #004080;
font-size: 1.1rem;
margin-bottom: 1rem;
border-bottom: 2px solid #eaeaea;
padding-bottom: 0.5rem;
}
label {
font-weight: 600;
color: #222;
display: block;
margin-bottom: 5px;
}
input {
width: 100%;
padding: 12px;
border: 1px solid #ccc;
border-radius: 10px;
font-size: 15px;
transition: border-color 0.3s;
margin-bottom: 15px;
}
input:focus {
border-color: #0070c9;
outline: none;
}
.btn {
width: 100%;
background: linear-gradient(90deg, #004080, #0070c0);
color: white;
border: none;
padding: 13px;
border-radius: 10px;
font-size: 16px;
cursor: pointer;
transition: background 0.3s;
font-weight: 600;
}
.btn:hover {
background-color: #005fa3;
}
.alert {
padding: 12px;
border-radius: 8px;
margin-bottom: 20px;
text-align: center;
font-size: 0.95rem;
}
.success {
background-color: #e8f8ec;
color: #2e8b57;
}
.error {
background-color: #fdecea;
color: #d93025;
}
/* Toggle Switch */
.toggle {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 1rem;
background: #f9f9f9;
padding: 12px 15px;
border-radius: 10px;
}
.switch {
position: relative;
width: 50px;
height: 25px;
}
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
position: absolute;
cursor: pointer;
top: 0; left: 0;
right: 0; bottom: 0;
background-color: #ccc;
transition: 0.4s;
border-radius: 25px;
}
.slider:before {
position: absolute;
content: "";
height: 19px;
width: 19px;
left: 3px;
bottom: 3px;
background-color: white;
transition: 0.4s;
border-radius: 50%;
}
input:checked + .slider {
background-color: #0070c0;
}
input:checked + .slider:before {
transform: translateX(24px);
}
.bottom-nav {
position: fixed;
bottom: 0;
left: 0;
width: 100%;
background: white;
display: flex;
justify-content: space-around;
border-top: 1px solid #ddd;
padding: 10px 0;
box-shadow: 0 -2px 8px rgba(0,0,0,0.05);
}
.bottom-nav a {
text-decoration: none;
color: #777;
font-weight: 500;
}
.bottom-nav .active {
color: #0070c0;
}
</style>
</head>
<body>
<div class="header">
<h2>Security & Privacy</h2>
<span onclick="history.back()">Back</span>
</div>
<div class="container">
<?php if ($success): ?>
<div class="alert success"><?= htmlspecialchars($success) ?></div>
<?php elseif ($error): ?>
<div class="alert error"><?= htmlspecialchars($error) ?></div>
<?php endif; ?>
<!--
<h3>Two-Factor Authentication (2FA)</h3>
<div class="toggle">
<span>Enable 2FA for extra protection</span>
<label class="switch">
<input type="checkbox" checked>
<span class="slider"></span>
</label>
</div> -->
<h3>Change Password</h3>
<form method="POST">
<label>New Password</label>
<input type="password" name="new_password" placeholder="Enter new password">
<button type="submit" class="btn">Update Password</button>
</form>
<h3>Change Transaction PIN</h3>
<form method="POST">
<label>New 4-Digit PIN</label>
<input type="password" name="new_pin" maxlength="4" placeholder="Enter new PIN">
<button type="submit" class="btn">Update PIN</button>
</form>
</div>
<div class="bottom-nav">
<a href="dashboard.php">🏠 Home</a>
<a href="transactions.php">💳 Transactions</a>
<a href="security_privacy.php" class="active">🔐 Security</a>
<a href="settings.php">⚙️ Settings</a>
</div>
</body>
</html>
b IDATxytVսϓ22 A@IR:hCiZ[v*E:WũZA ^dQeQ @ !jZ'>gsV仿$|?g)&x-E