<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);


$debugMessage = "The script is accessible.";

// Output JavaScript code that sends the message to the console
echo "<script>console.log('" . addslashes($debugMessage) . "');</script>";


// if ($_SERVER['REQUEST_METHOD'] === 'POST') {
//     // Collect the form data
//     $url = $_POST['url'];
//     $liked = $_POST['liked'];
//     $improvement = $_POST['improvement'];
//     $rating = $_POST['rating'];
//     $email = $_POST['email'];

//     // Path to your SQLite database file
//     $dbFile = '/feedback/webhelp-feedback.db';

//     // Create (or open) the SQLite database
//     $conn = new PDO("sqlite:$dbFile");

//     // Set the PDO error mode to exception
//     $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

//     // Prepare an SQL statement to insert the form data
//     $stmt = $conn->prepare("INSERT INTO feedback_table (url, liked, improvement, rating, email) VALUES (:url, :liked, :improvement, :rating, :email)");
    
//     // Bind parameters
//     $stmt->bindParam(':url', $url);
//     $stmt->bindParam(':liked', $liked);
//     $stmt->bindParam(':improvement', $improvement);
//     $stmt->bindParam(':rating', $rating);
//     $stmt->bindParam(':email', $email);

//     // Execute the statement
//     if ($stmt->execute()) {
//         echo 'Feedback submitted successfully!';
//     } else {
//         echo 'There was an error submitting your feedback. Please try again later.';
//     }

//     // Close the connection
//     $conn = null;

//     // (Optional) Redirect to a thank you page
//     // header('Location: thank-you.html');
// } else {
//     echo 'Invalid request method.';
// }
?>
