prepare("SELECT * FROM testimonials WHERE id = ?"); $stmt->execute([$id]); $testimonial = $stmt->fetch(); if ($testimonial) { $client_name = $testimonial['client_name']; $rating = $testimonial['rating']; $comment = $testimonial['comment']; $designation = $testimonial['designation']; $is_edit = true; } else { $error = 'Testimonial not found.'; } } catch (PDOException $e) { $error = 'Database lookup failed: ' . $e->getMessage(); } } else { $error = 'Invalid testimonial ID.'; } } // Handle Form Submission if ($_SERVER['REQUEST_METHOD'] === 'POST') { $client_name = trim($_POST['client_name'] ?? ''); $rating = filter_var($_POST['rating'] ?? 5, FILTER_VALIDATE_INT); $comment = trim($_POST['comment'] ?? ''); $designation = trim($_POST['designation'] ?? ''); // Check fields if (empty($client_name) || empty($comment) || $rating === false || $rating < 1 || $rating > 5) { $error = 'Please fill out all required fields and provide a rating between 1 and 5.'; } else { try { if ($is_edit) { // Update $sql = "UPDATE testimonials SET client_name = :client_name, rating = :rating, comment = :comment, designation = :designation WHERE id = :id"; $stmt = $pdo->prepare($sql); $stmt->execute([ ':client_name' => $client_name, ':rating' => $rating, ':comment' => $comment, ':designation' => $designation, ':id' => $id ]); $success = 'Testimonial updated successfully!'; } else { // Insert $sql = "INSERT INTO testimonials (client_name, rating, comment, designation) VALUES (:client_name, :rating, :comment, :designation)"; $stmt = $pdo->prepare($sql); $stmt->execute([ ':client_name' => $client_name, ':rating' => $rating, ':comment' => $comment, ':designation' => $designation ]); $success = 'Testimonial added successfully!'; // Clear fields on success for new entry $client_name = ''; $rating = 5; $comment = ''; $designation = ''; } } catch (PDOException $e) { $error = 'Failed to save testimonial: ' . $e->getMessage(); } } } include '../includes/admin_header.php'; ?>

Back to Testimonials
View in List →
Testimonial Information
Specify the customer feedback details. Ratings are displayed as star values.
This will appear under the client name (default is "Homeowner" if empty).
Writing Guidelines
  • Keep comments concise (ideally between 150 to 300 characters) so they look neat in the homepage slider.
  • Ensure client names are formatted with correct casing.
  • Ratings directly affect the number of filled stars displayed alongside their name.
  • Designations help establish credibility (e.g., adding "Interior Designer" or "Hotel Owner" showcases commercial client reach).