BLACKSITE
:
216.73.216.140
:
199.188.200.160 / jeddahhousingltd.com
:
Linux server383.web-hosting.com 4.18.0-553.83.1.lve.el8.x86_64 #1 SMP Wed Nov 12 10:04:12 UTC 2025 x86_64
:
/
home
/
jeddveug
/
www
/
admin
/
Upload File:
files >> /home/jeddveug/www/admin/member_edit.php
<?php require_once __DIR__ . '/../config/db.php'; // Check authentication if (!isset($_SESSION['admin_id'])) { header('Location: login.php'); exit; } $id = (int)($_GET['id'] ?? 0); if (!$id) { header('Location: members.php'); exit; } $stmt = $pdo->prepare("SELECT * FROM members WHERE id = ?"); $stmt->execute([$id]); $member = $stmt->fetch(); if (!$member) { header('Location: members.php'); exit; } $errors = []; if ($_SERVER['REQUEST_METHOD'] === 'POST') { $name = trim($_POST['name'] ?? ''); $designation = trim($_POST['designation'] ?? ''); $phone = trim($_POST['phone'] ?? ''); $email = trim($_POST['email'] ?? ''); $bio = trim($_POST['bio'] ?? ''); $display_order = (int)($_POST['display_order'] ?? 0); if (!$name) $errors[] = 'Name is required.'; $image_name = $member['image']; if (isset($_FILES['image']) && $_FILES['image']['error'] === UPLOAD_ERR_OK) { $allowed = ['image/jpeg','image/png','image/webp']; if (in_array($_FILES['image']['type'], $allowed)) { if ($member['image'] && file_exists('../uploads/members/' . $member['image'])) unlink('../uploads/members/' . $member['image']); $ext = pathinfo($_FILES['image']['name'], PATHINFO_EXTENSION); $image_name = 'member_' . time() . '_' . rand(100,999) . '.' . $ext; move_uploaded_file($_FILES['image']['tmp_name'], '../uploads/members/' . $image_name); } else { $errors[] = 'Invalid image format.'; } } if (empty($errors)) { $stmt = $pdo->prepare("UPDATE members SET name=?, designation=?, phone=?, email=?, image=?, bio=?, display_order=? WHERE id=?"); $stmt->execute([$name, $designation, $phone, $email, $image_name, $bio, $display_order, $id]); header('Location: members.php?msg=updated'); exit; } } else { $name = $member['name']; $designation = $member['designation']; $phone = $member['phone']; $email = $member['email']; $bio = $member['bio']; $display_order = $member['display_order']; } $admin_page_title = 'Edit Member'; require_once 'includes/header.php'; ?> <div class="max-w-3xl"> <a href="members.php" class="text-sm text-primary-600 hover:text-primary-800 mb-4 inline-flex items-center"><i class="fas fa-arrow-left mr-2"></i> Back to Members</a> <?php if (!empty($errors)): ?> <div class="bg-red-50 border border-red-200 text-red-700 px-4 py-3 rounded-xl mb-5 text-sm"> <?php foreach ($errors as $err): ?><p>• <?= htmlspecialchars($err) ?></p><?php endforeach; ?> </div> <?php endif; ?> <form method="POST" enctype="multipart/form-data" class="bg-white rounded-xl shadow-sm p-6 space-y-5"> <div class="grid grid-cols-1 sm:grid-cols-2 gap-4"> <div> <label class="block text-sm font-medium text-gray-700 mb-1">Name <span class="text-red-500">*</span></label> <input type="text" name="name" required value="<?= htmlspecialchars($name) ?>" class="w-full px-4 py-2.5 border border-gray-300 rounded-xl text-sm"> </div> <div> <label class="block text-sm font-medium text-gray-700 mb-1">Designation</label> <input type="text" name="designation" value="<?= htmlspecialchars($designation) ?>" class="w-full px-4 py-2.5 border border-gray-300 rounded-xl text-sm"> </div> </div> <div class="grid grid-cols-1 sm:grid-cols-2 gap-4"> <div> <label class="block text-sm font-medium text-gray-700 mb-1">Phone</label> <input type="text" name="phone" value="<?= htmlspecialchars($phone) ?>" class="w-full px-4 py-2.5 border border-gray-300 rounded-xl text-sm"> </div> <div> <label class="block text-sm font-medium text-gray-700 mb-1">Email</label> <input type="email" name="email" value="<?= htmlspecialchars($email) ?>" class="w-full px-4 py-2.5 border border-gray-300 rounded-xl text-sm"> </div> </div> <div> <label class="block text-sm font-medium text-gray-700 mb-1">Photo</label> <?php if ($member['image']): ?> <div class="mb-2"><img src="../uploads/members/<?= htmlspecialchars($member['image']) ?>" class="w-20 h-20 rounded-full object-cover"></div> <?php endif; ?> <input type="file" name="image" accept="image/*" class="w-full px-4 py-2.5 border border-gray-300 rounded-xl text-sm file:mr-4 file:py-1 file:px-3 file:rounded-lg file:border-0 file:bg-primary-50 file:text-primary-700 file:font-medium file:text-sm"> <p class="text-xs text-gray-400 mt-1">Leave empty to keep current photo</p> </div> <div> <label class="block text-sm font-medium text-gray-700 mb-1">Bio</label> <textarea name="bio" rows="3" class="w-full px-4 py-2.5 border border-gray-300 rounded-xl text-sm"><?= htmlspecialchars($bio) ?></textarea> </div> <div> <label class="block text-sm font-medium text-gray-700 mb-1">Display Order</label> <input type="number" name="display_order" value="<?= $display_order ?>" class="w-full px-4 py-2.5 border border-gray-300 rounded-xl text-sm"> </div> <button type="submit" class="bg-primary-700 hover:bg-primary-800 text-white px-6 py-2.5 rounded-xl text-sm font-medium transition-colors"><i class="fas fa-save mr-2"></i>Update Member</button> </form> </div> <?php require_once 'includes/footer.php'; ?>