<?php
session_start();
include "conn/config.php";
date_default_timezone_set("PRC");
if($_POST['sub']){
	$title = trim($_POST['title']);
	$editor = trim($_POST['editor1']);
	$id = $_SESSION['user_id'];
	$time = date("Y-m-d H:i:s");
	$query = mysql_query("select * from {$total_pr}user where id='".$id."'");
	while($row = mysql_fetch_array($query)){
		$author = $row['username'];
	}
	
	if($title == ""){
		echo '<script type="text/javascript">alert("文章标题不能为空！");history.back();</script>';
		exit();
	}
	
	if($editor == ""){
		echo '<script type="text/javascript">alert("文章内容不能为空！");history.back();</script>';
		exit();
	}
	
	$query = mysql_query("insert into {$total_pr}article(userid,title,content,author,atime) values('$id','$title','$editor','$author','$time') ");
	if($query){
		mysql_query("update {$total_pr}user set point=point+1 where id='".$_SESSION['user_id']."'");
		header("location:index.php");
	}else{
	   	echo '<script type="text/javascript">alert("文章afdasfjsfsafd！");</script>';
	}
}

?>