My Profile
Manage your account information
'Seji Ahmad', 'email' => 'admin@globalwebix.in', 'phone' => '7880588713', 'bio' => 'Founder of GlobalWebix', 'role' => 'Super Admin', 'image' => 'https://via.placeholder.com/150' ]; // ========================================================= // 4. HANDLE FORM SUBMISSION (UPDATE PROFILE) // ========================================================= $msg = ""; $msg_type = ""; if (isset($_POST['update_profile']) && isset($con)) { $name = htmlspecialchars($_POST['name']); $email = htmlspecialchars($_POST['email']); $phone = htmlspecialchars($_POST['phone']); $bio = htmlspecialchars($_POST['bio']); // Image Path Logic $image_path = $user['image']; // Default keep old // Fetch Old Image from DB to be sure $stmt_old = $con->prepare("SELECT image FROM admins WHERE id = ?"); $stmt_old->bind_param("i", $admin_id); $stmt_old->execute(); $res_old = $stmt_old->get_result(); if($row_old = $res_old->fetch_assoc()){ if(!empty($row_old['image'])) $image_path = $row_old['image']; } // Check New Upload if (isset($_FILES['profile_img']['name']) && $_FILES['profile_img']['name'] != "") { $target_dir = "uploads/"; if (!file_exists($target_dir)) { mkdir($target_dir, 0777, true); } $file_name = time() . "_" . basename($_FILES["profile_img"]["name"]); $target_file = $target_dir . $file_name; $imageFileType = strtolower(pathinfo($target_file, PATHINFO_EXTENSION)); if (in_array($imageFileType, ['jpg', 'jpeg', 'png'])) { if (move_uploaded_file($_FILES["profile_img"]["tmp_name"], $target_file)) { $image_path = $target_file; } } else { $msg = "Only JPG/PNG Allowed."; $msg_type = "error"; } } if ($msg == "") { $update = $con->prepare("UPDATE admins SET name=?, email=?, phone=?, bio=?, image=? WHERE id=?"); $update->bind_param("sssssi", $name, $email, $phone, $bio, $image_path, $admin_id); if ($update->execute()) { $msg = "Profile Updated Successfully!"; $msg_type = "success"; // Update Session for Header display $_SESSION['admin_name'] = $name; } else { $msg = "Database Error: " . $con->error; $msg_type = "error"; } } } // ========================================================= // 5. FETCH REAL DATA FROM DB // ========================================================= if (isset($con)) { $stmt = $con->prepare("SELECT * FROM admins WHERE id = ?"); $stmt->bind_param("i", $admin_id); if ($stmt->execute()) { $result = $stmt->get_result(); if ($result->num_rows > 0) { // Overwrite default data with Real DB Data $db_data = $result->fetch_assoc(); // Merge carefully to avoid missing keys $user = array_merge($user, $db_data); } } } // ========================================================= // 6. INCLUDES (Design Files) // ========================================================= // Include header/sidebar safely if(file_exists('includes/header.php')) include 'includes/header.php'; if(file_exists('includes/sidebar.php')) include 'includes/sidebar.php'; ?>
Manage your account information