<?php
session_start();
include("config.php");
if (isset($_POST['message'])) {
    $user = $_SESSION['user_name'];
    $msg = mysqli_real_escape_string($conn, $_POST['message']);
    mysqli_query($conn, "INSERT INTO chat_messages (user_name, message) VALUES ('$user', '$msg')");
}
?>