<?php
	require("../__common__/__define_mobile.php");
	require("__define.php");
	$login_id = mobile_login_check();
	if ($_POST) {
		post_done_proc();
	} else {
		form_proc();
	}
	exit();
function form_proc() {
?>
<!DOCTYPE html>
<html lang="ja">
<head>
<?php
	mobile_common_head('myHome チャット');
?>
</head>
<body>
<div data-role="page" id="sample_button">
	<div data-role="header">
		<a href="../chat" data-icon="back" rel="external">戻る</a>
		<h1>チャット</h1>
	</div>
	<div data-role="content">
		<div data-role="fieldcontain">
			<form method="post" action="">
			<label for="account">投稿内容：</label>
				<textarea name="message" id="message" style="width:97%;height:100px;" wrap="soft"></textarea>
			<div data-inline="true">
				<input type="submit" value="投稿" data-theme="b" data-inline="true">
				<input type="reset" value="クリア" data-inline="true">
			</div>
			</form>
		<?= $errmsg ?>
		</div>
	</div>
</div>
</body>
</html>
<?php
}
function post_done_proc() {
	if ($_POST["message"].'' == '') {
		exit;
	}
	$con = mobile_mysql_connect(_DB_SCHEMA);
	$sql = "insert into m_messages (id_account,c_message,c_registtime)";
	$sql .= " values ('" . $_SESSION['mobile_login_id'] . "','" . str_for_mysql(form_str_adjust($_POST["message"])) . "','" . date("Y/m/d H:i:s") ."')";
	my_mysql_query($sql);
	$con = mysql_close($con);
	redirect('../chat');
}
?>
