<HEAD>
<TITLE>SAVE(sxxncw.cn)</TITLE>
<META content=zh-cn http-equiv=Content-Language>
<META content="text/html; charset=gb2312" http-equiv="Content-Type">
<meta name="keywords" content="山西新农村网 - 内参阅读">
<meta name="description" content="山西新农村网 - 内参阅读">
<body>
<?php
header('Cache-control: private, must-revalidate');
/*
* SQL注入过滤
*/
/*
* 包含文件
*/
require("e/class/connect.php");
/*
* 将当前时间转换成...
*/
$stringtime = date("Y-m-d H:i:s",time());
//echo $stringtime."<br/>";
$time1 = to_time($stringtime); /* 转换成unix时间 */
//echo $time1;
/*
echo to_time('2009-10-20 12:40:20');
*/
//echo "<br><hr>";
/*
* 连接数据库
*/
$con = mysql_connect("localhost","root","");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_query("set names 'gbk'");//这就是指定数据库字符集,一般放在连接数据库后面
/*
* 选择操作数据库
*/
mysql_select_db("empirecms", $con);
/*
$sql="INSERT INTO phome_ecms_article (title,smalltext,keyboard) VALUES ('$_POST[t]','$_POST[c]','http://www.sxxncw.com/flv/1.flv')";
农民吧的classid = 81
stb:sub table (子表)
username = 游客 (注册的一个用户名,作为公共用户来使用,建议登陆会员从会员区投稿)
newstempid = 16 模板id 农民吧内容页专用的模板
*/
/*
* 插入主表(无新闻内容)
*/
$sql="INSERT INTO phome_ecms_news (classid,title,smalltext,username,userid,stb,checked,newstempid,dokey,filename,zherenbianji,newstime) VALUES (81,'$_POST[t]','$_POST[c]','游客',3,'1',0,16,1,0,'艳萍',".$time1 .")";
//echo $sql;
//echo "<br>";
if (!mysql_query($sql,$con))
{
die('Error: ' . mysql_error());
}
$newid = mysql_insert_id(); /* 记下新增的这条的id,以备更新文件名 */
//echo $newid;
//echo "<br>";
/*
* 在副表中插入文件内容
*/
$sql_sub="INSERT INTO phome_ecms_news_data_1 (id,classid,writer,befrom,newstext) VALUES (".$newid .",81,'游客','游客发言','$_POST[c]')";
//echo $sql_sub;
//echo "<br>";
if (!mysql_query($sql_sub,$con))
{
die('Error: ' . mysql_error());
}
/*
* 更新文件名,文件名为insert时自动递增的id
*/
$sql_filename="UPDATE phome_ecms_news SET filename = " .$newid ." WHERE id = " .$newid ;
//echo $sql_filename;
//echo "<br>";
if (!mysql_query($sql_filename,$con))
{
die('Error: ' . mysql_error());
}
echo "成功增加一条记录";
mysql_close($con);
?>
<script type="text/javascript">
window.close();
</script>
</body>
</html>
评论