<?php

            include('../../config/config.php');
            date_default_timezone_set('Africa/Lagos');
            
            include('../messaging/whatsapp/index.php');
            
            // Set CORS headers to allow requests from any origin (*)
            header("Access-Control-Allow-Origin: *");
            
            // Allow specific HTTP methods
            header("Access-Control-Allow-Methods: GET, POST, PUT, DELETE");
            
            // Allow specific HTTP headers
            header("Access-Control-Allow-Headers: Content-Type, Authorization");
            
            // Allow cookies to be included in the request (if needed)
            header("Access-Control-Allow-Credentials: true");
            
            // Retrieve the raw POST data
            $UserID = isset($_POST['UserID']) ? mysqli_real_escape_string($link, trim($_POST['UserID'])) : '';
            $UserType = isset($_POST['UserType']) ? mysqli_real_escape_string($link, trim($_POST['UserType'])) : '';
            $fname = isset($_POST['fname']) ? mysqli_real_escape_string($link, trim($_POST['fname'])) : '';
            $lname= isset($_POST['lname']) ? mysqli_real_escape_string($link, trim($_POST['lname'])) : '';
            $phone= isset($_POST['phone']) ? mysqli_real_escape_string($link, trim($_POST['phone'])) : '';
            
        
            
            $pros_verify_tribe = mysqli_query($link, "UPDATE `Users` SET `UserFirstName`='$fname', `UserLastName`='$lname', `Phone`='$phone' WHERE `UserID`='$UserID'");
            
            if ($pros_verify_tribe == true) {
                $response = array(
                    "requestSuccessful" => true,
                    "responseMessage" => "success",
                    "responseDescription" => "Profile edited successfully"
                );
            } else {
                $response = array(
                    "requestSuccessful" => false, // Assuming the request was not successful
                    "responseMessage" => "failed",
                    "responseDescription" => "profile could not be editted, please try again later!!"
                );
            }
            
            $json_response = json_encode($response);
            
            // Output the JSON response
            echo $json_response;

?>
