<?php

	include "library.php";

	$cxn = start_code( true );


		/* get parameters */

	$conversation_id = val( $_GET, 'conversationid' );

	$member_id = val( $_GET, 'memberid' );

	$text = val( $_GET, 'text' );


		/* check them */

	crash_if_missing( $conversation_id, "conversation_id missing in save_chat_text", $cxn );
	
	crash_if_missing( $member_id, "member_id missing in save_chat_text", $cxn );


		/* save text typed */

	$typed = date("Y-m-d H:i:s");

	$query = "INSERT INTO chat_text (conversation_id, typed_by, text, typed) VALUES (".$conversation_id.", ".$member_id.", '".$text."', '".$typed."')";

	$result = run_query( $query, $cxn );

	
	$typed = date("Y-m-d H:i:s");

	$query = "INSERT INTO chat_text_history (conversation_id, typed_by, text, typed) VALUES (".$conversation_id.", ".$member_id.", '".$text."', '".$typed."')";

	$result = run_query( $query, $cxn );

	echo "ok";

?>
