<?php
include_once('database.php'); 
include('functions.php'); 


// Process form submission
if ($_SERVER["REQUEST_METHOD"] === "POST") {
  // Escape user inputs to prevent SQL injection

  $name_contact = mysqli_real_escape_string($conn, $_POST['name_contact']);
  $lastname_contact = mysqli_real_escape_string($conn, $_POST['lastname_contact']);
  $email_contact = mysqli_real_escape_string($conn, $_POST['email_contact']);
  $phone_contact = mysqli_real_escape_string($conn, $_POST['phone_contact']);
  $message_contact = mysqli_real_escape_string($conn, $_POST['message_contact']);
  $category_contact = mysqli_real_escape_string($conn, $_POST['category_contact']);


                     
                      
  
  $contact_data = [
    [
        'key' => 'first_name',
        'value' => $name_contact,
        'param' => 's'
    ],
    [
        'key' => 'last_name',
        'value' => $lastname_contact,
        'param' => 's'
    ],
    [
        'key' => 'email',
        'value' => $email_contact,
        'param' => 's'
    ],
    [
        'key' => 'phone',
        'value' => $phone_contact,
        'param' => 's'
    ],
    [
        'key' => 'category',
        'value' => $category_contact,
        'param' => 's'
    ],
    [
        'key' => 'message',
        'value' => $message_contact,
        'param' => 's'
    ]
];


insertRecord($conn, 'contacts', $contact_data);

$booking_notifications = [
    [
        'key' => 'title',
        'value' => 'New Message Received',
        'param' => 's'
    ],
    [
        'key' => 'image',
        'value' => 'assets/images/apps/01.png',
        'param' => 's'
    ],
    [
        'key' => 'text',
        'value' => 'You have a new message from '. ($name_contact .' '. $lastname_contact),
        'param' => 's'
    ]
    ];

insertRecord($conn, 'notifications', $booking_notifications);

header("Location: ../contact-us.html");

}
  



