<?php
require_once 'core.php';

  $to_user_id   = $_POST['to_user_id'];
  $chat_message = $_POST['chat_message'];
  $from_user_id = $_SESSION['user_id'];
  $status = '1';

 $query = "INSERT INTO txmessage_chat 
         (ftname_sender, ftrecipient_msg, ftfill_msg, fnstatus) 
   VALUES ('$from_user_id', '$to_user_id', '$chat_message', '$status')";
 
  $result = mysqli_query($link,$query);

  //ketika chat berhasil terkirim maka chat history akan tampil 
  
  if($result){
 
     echo fetch_user_chat_history($from_user_id,$to_user_id);

  }
  

?>
