<?php
if(!defined('IN_TM')) {exit('Access Denied');}
if(empty($_REQUEST['Submit'])){
		$tplid = 2;
		$db->close();
		include template('guestbook.htm');
}else{
		$title = getgpc('title');
		$xz = getgpc('xz');
		$name = getgpc('name');
		$tel = getgpc('tel');
		$mail = getgpc('mail');
		$body = getgpc('body');
		if(empty($title)){
			die("<script>alert('请填写留言标题!重要！'); history.go(-1);</script>");
		}elseif(empty($name)){
			die("<script>alert('请输入您的名字！'); history.go(-1);</script>");
		}elseif(empty($body)){
			die("<script>alert('请输入留言内容！'); history.go(-1);</script>");
		}
		$sql = "INSERT INTO `{$tablepre}guestbook` (`title` ,`xz` ,`name` ,`tel` ,`email` ,`body` ,`time`)VALUES ('$title', '$xz', '$name', '$tel','$mail','$body', '$timestamp');";
		$rs = $db->query($sql);
		if($rs){
			die("<script>alert('恭喜，您的留言我们已经记录到数据库中，稍后管理员会查看您的留言，谢谢！');history.go(-1);</script>");
		}else{
			die("<script>alert('服务器繁忙请稍后再试！'); history.go(-1);</script>");
		}
	}
?>