🤩 File Manager - Mr.X
PHP:
8.3.33
Server:
Apache
OS:
Linux 5.14.0-611.49.1.el9_7.x86_64
User:
websparkit
Navigate
Upload:
Upload
New File
New Folder
Editing:profile.php
<?php require_once __DIR__ . '/../config/config.php'; require_once __DIR__ . '/../includes/functions.php'; if (!isLoggedIn()) redirect(SITE_URL . 'customer/login.php'); $customer = getCustomer($_SESSION['customer_id']); $msg = ''; if ($_SERVER['REQUEST_METHOD'] == 'POST') { $name = cleanInput($_POST['name']); $phone = cleanInput($_POST['phone']); $address = cleanInput($_POST['address']); $district = cleanInput($_POST['district']); $stmt = $conn->prepare("UPDATE customers SET name=?, phone=?, address=?, district=? WHERE id=?"); $stmt->bind_param("ssssi", $name, $phone, $address, $district, $_SESSION['customer_id']); if ($stmt->execute()) { $_SESSION['customer_name'] = $name; $msg = '<div class="alert alert-success">Profile updated successfully!</div>'; $customer = getCustomer($_SESSION['customer_id']); } else { $msg = '<div class="alert alert-danger">Update failed.</div>'; } if (!empty($_POST['current_password']) && !empty($_POST['new_password'])) { if (password_verify($_POST['current_password'], $customer['password'])) { $np = password_hash($_POST['new_password'], PASSWORD_DEFAULT); $stmt = $conn->prepare("UPDATE customers SET password=? WHERE id=?"); $stmt->bind_param("si", $np, $_SESSION['customer_id']); $stmt->execute(); $msg .= '<div class="alert alert-success">Password changed!</div>'; } else { $msg .= '<div class="alert alert-danger">Current password is wrong.</div>'; } } } define('PAGE_TITLE', 'Profile'); include 'dashboard-header.php'; ?> <div class="d-flex justify-content-between align-items-center mb-4"> <h4 class="fw-bold text-navy mb-0"><i class="bi bi-person-circle text-warning me-2"></i>My Profile</h4> </div> <?= $msg ?> <div class="premium-card p-4 p-lg-5"> <form method="post"> <div class="row g-3"> <div class="col-md-6"><label class="form-label">Full Name</label><input type="text" name="name" class="form-control" value="<?= htmlspecialchars($customer['name']) ?>" required></div> <div class="col-md-6"><label class="form-label">Email</label><input type="email" class="form-control" value="<?= htmlspecialchars($customer['email']) ?>" disabled></div> <div class="col-md-6"><label class="form-label">Phone Number</label><input type="tel" name="phone" class="form-control" value="<?= htmlspecialchars($customer['phone']) ?>" required></div> <div class="col-md-6"><label class="form-label">District</label><select name="district" class="form-select"><option value="">Select</option><?php foreach(['Colombo','Gampaha','Kalutara','Kandy','Galle','Matara','Jaffna','Kurunegala','Anuradhapura'] as $d): ?><option <?= $customer['district']==$d?'selected':'' ?>><?= $d ?></option><?php endforeach; ?></select></div> <div class="col-12"><label class="form-label">Address</label><textarea name="address" class="form-control" rows="2"><?= htmlspecialchars($customer['address']) ?></textarea></div> <div class="col-12"><button type="submit" class="btn btn-premium"><i class="bi bi-check-circle me-2"></i>Update Profile</button></div> </div> </form> <hr class="my-4"> <h5 class="fw-bold mb-3">Change Password</h5> <form method="post" class="row g-3"> <div class="col-md-4"><label class="form-label">Current Password</label><input type="password" name="current_password" class="form-control"></div> <div class="col-md-4"><label class="form-label">New Password</label><input type="password" name="new_password" class="form-control" minlength="6"></div> <div class="col-md-4"><label class="form-label"> </label><button type="submit" class="btn btn-navy w-100"><i class="bi bi-key me-2"></i>Change Password</button></div> </form> </div> <?php include 'dashboard-footer.php'; ?>
Save Changes
Cancel
Create New File
Create New Folder