<?php
// Start the session
session_start();
// Include database connection and other necessary files
include 'head.php';
// Check if form data is submitted
if(isset($_POST['btnSaveTestimonial'])){
// Retrieve form data
// $userid = $_SESSION['userid'];
$name = $_POST['name'];
$testimonial = $_POST['testimonial'];
$country = $_POST['country'];
$title = $_POST['title'];
// Insert data into database
$insertSql = "INSERT INTO testimonials (name, title, testimonial, country)
VALUES ('$name', '$title', '$testimonial', '$country')";
if ($conn->query($insertSql) === TRUE) {
// Redirect back to manage-testimonials.php after successful insertion
header("Location: manage-testimonials.php");
exit(); // Ensure no further code execution after redirection
} else {
echo "Error inserting record into database: " . $conn->error;
}
}
?>