<?php 
require_once 'config.php';
$error=false;
$errors=array();
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
  $thread_id=$_POST['thread_id'];
 $from_user=$_POST['from_user'];
  $to_user=$_POST['to_user'];
  $message=$_POST['message'];

  
	$createEmployee=mysqli_query($con,"INSERT INTO messages (thread_id,from_user,to_user,message,created_at,status) VALUES('".$thread_id."','".$from_user."','".$to_user."','".$message."','".date('Y-m-d H:i:s')."',1)");
	 if($createEmployee){
	     	$errors['success']='Messages sent Sucessfully';
	 }else{
	     $errors['success']='Somthing went wrong !!';
	 }
   
 	 
	 	echo json_encode($errors);
}