Suvodip 2025-03-25 13:24:55 +05:30
parent a8c21c995c
commit 7dcd87c174
5 changed files with 132 additions and 7 deletions

View File

@ -10,9 +10,7 @@
</button>
<div class="collapse navbar-collapse" id="navbarNav">
<ul class="navbar-nav ms-auto">
<li class="nav-item">
<a class="nav-link active" href="/" style="color: #374151;">Home</a>
</li>
<!-- <li class="nav-item"><a class="nav-link active" href="/" style="color: #374151;">Home</a></li> -->
<?php
if(isset($_SESSION['isLogedin']) && $_SESSION['isLogedin'] === true){
if(isset($_SESSION['userType']) && $_SESSION['userType'] === 'admin'){
@ -31,13 +29,22 @@
} elseif(isset($_SESSION['userType']) && $_SESSION['userType'] === 'user')
echo '
<li class="nav-item">
<a class="nav-link" href="/my-account" style="color: #374151;">My Account</a>
<a class="nav-link" href="/my-account" style="color: #374151;">My Account</a>
</li>';
}
?>
<li class="nav-item">
<a class="nav-link" href="/contact-us" style="color: #374151;">Contact</a>
</li>
<?php
if(isset($_SESSION['isLogedin']) && $_SESSION['isLogedin'] === true){
echo '
<li class="nav-item">
<a class="nav-link" href="/profile" style="color: #374151;">Profile</a>
</li>
';
}
?>
<li class="nav-item">
<?php
if (isset($_SESSION['isLogedin']) && $_SESSION['isLogedin'] === true) {

View File

@ -21,7 +21,7 @@
$_SESSION['customerId'] = $user['customerId'];
// var_dump($_SESSION);
echo "Login successful! Welcome, " . htmlspecialchars($user['email']);
header("Location: /");
header("Location: /profile");
// var_dump($_SESSION);
} else {
echo "Invalid email or password.";

View File

@ -8,6 +8,6 @@ $_SESSION = [];
session_destroy();
// Redirect to login page
header("Location: /");
header("Location: /login");
exit;
?>

118
.hta_slug/profile.php Normal file
View File

@ -0,0 +1,118 @@
<?php
if (!isset($_SESSION['isLogedin']) || $_SESSION['isLogedin'] != 1) {
header("Location: /login");
exit;
}
// Password update query
if($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['update_password'])){
try {
$db = new PDO("mysql:host=$mariaServer;dbname=$mariaDb", $mariaUser, $mariaPass);
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$email = $_SESSION['userEmail'];
$newPassword = md5($_POST['new_password']);
$stmt = $db->prepare("UPDATE users SET password = :password WHERE email = :email");
$stmt->bindParam(':password', $newPassword, PDO::PARAM_STR);
$stmt->bindParam(':email', $email, PDO::PARAM_STR);
if ($stmt->execute()) {
echo '<div class="alert alert-success">Password updated successfully!</div>';
} else {
echo '<div class="alert alert-danger">Failed to updated Password.</div>';
}
// $stmt->execute();
// echo "Password updated successfully!";
} catch (PDOException $e) {
echo "Error: " . $e->getMessage();
}
}
?>
<style>
.profile-container {
max-width: 600px;
margin: 80px auto;
}
.profile-card {
background: #fff;
border-radius: 10px;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
padding: 20px;
}
.profile-header {
text-align: center;
margin-bottom: 20px;
}
.profile-header img {
width: 80px;
height: 80px;
border-radius: 50%;
margin-bottom: 10px;
}
.btn-primary {
background: #394fc0;
border: none;
}
.btn-primary:hover {
background: #2e3b8c;
}
</style>
<div class="profile-container">
<div class="profile-card">
<div class="profile-header">
<svg style="background-color: #37415110; border: 2px solid #374151;border-radius: 50%; padding: 3px; box-shadow: 0 0 10px 0;" width="100px" height="100px" viewBox="0 0 32 32" xmlns="http://www.w3.org/2000/svg" fill="#000000"><g id="SVGRepo_bgCarrier" stroke-width="0"></g><g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"></g><g id="SVGRepo_iconCarrier"> <defs> <style>.cls-1{fill:#374151;}.cls-2{fill:#374151;}</style> </defs> <title></title> <g id="fill"> <circle class="cls-1" cx="16" cy="7.48" r="5.48"></circle> <path class="cls-2" d="M23.54,30H8.46a4.8,4.8,0,0,1-4.8-4.8h0A10.29,10.29,0,0,1,13.94,14.92h4.12A10.29,10.29,0,0,1,28.34,25.2h0A4.8,4.8,0,0,1,23.54,30Z"></path> </g> </g></svg>
<h3 class="fw-bold mt-2">Welcome, <?php echo $_SESSION['userName']; ?>!</h3>
<p class="text-muted">Email: <?php echo $_SESSION['userEmail']; ?></p>
</div>
<div class="mt-3">
<h5>Change Password</h5><hr>
<form method="POST">
<div class="mb-3">
<input type="password" class="form-control" id="currentPassword" name="current_password" placeholder="Current Password" required>
</div>
<div class="mb-3">
<input type="password" class="form-control" id="newPassword" name="new_password" placeholder="New Password" required>
</div>
<div class="mb-3">
<input type="password" class="form-control" id="confirmPassword" name="confirm_password" placeholder="Confirm New Password" required>
</div>
<button name="update_password" type="submit" class="btn w-100 text-white" style="background-color: #374151">Update Password</button>
</form>
</div>
</div>
</div>
<script>
document.addEventListener("DOMContentLoaded", function () {
const form = document.querySelector("form");
const newPassword = document.getElementById("newPassword");
const confirmPassword = document.getElementById("confirmPassword");
const submitBtn = document.querySelector("button[type='submit']");
const errorMessage = document.createElement("small");
errorMessage.style.color = "red";
confirmPassword.parentNode.appendChild(errorMessage);
confirmPassword.addEventListener("input", function () {
if (newPassword.value !== confirmPassword.value) {
errorMessage.style.color = "red";
errorMessage.textContent = "Passwords do not match!";
submitBtn.disabled = true;
} else {
errorMessage.style.color = "green";
errorMessage.textContent = "Passwords matched!";
submitBtn.disabled = false;
}
});
form.addEventListener("submit", function (e) {
if (newPassword.value !== confirmPassword.value) {
e.preventDefault();
errorMessage.textContent = "Passwords do not match!";
submitBtn.disabled = true;
}
});
});
</script>

View File

@ -221,7 +221,7 @@
if($emiPlans[0]['adPaymentAmount'] > 0 ) { ?>
<h3 class="mb-3">Additional Payment Details</h3>
<table class="table table-striped table-bordered">
<thead class="bg-primary text-white text-center">
<thead class="text-white text-center" style="background-color: #374151;">
<tr>
<th>Amount</th>
<th>Payment Date</th>