<?php
	session_start();
	include 'conn/conn.php';
	$title = $_POST['title'];
	$content = $_POST['cont'];
	if(empty($title) or empty($content)){
		echo "<script>alert('请填写留言内容');history.go(-1);</script>";
		exit();
	}
	$insertsql = "insert into tb_mess (title,content,author) values('".$title."','".$content."','".(empty($_SESSION['name'])?'匿名':$_SESSION['name'])."');";
	mysql_query($insertsql);
	if(mysql_affected_rows() == 1){
		echo "<script>alert('留言发表成功!');location='index.php';</script>";
		exit();
	}else{
		echo mysql_error();
	}
?>