<?php
require_once("dbconn.php");
require_once("phpFunctions.php");

if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $username = $_POST["username"];
    $message = $_POST["message"];

	$result = executeQuery($conn, "INSERT INTO chatdb (username, message) VALUES (?, ?)", "ss", [$username, $message]);
    
	if ($result === false) { 
		throw new Exception("Error executing query: " . $conn->error);
	} 
}
?>