📄 14-20.php
字号:
<?php
echo "<html>\n"; //输出标准HTML内容
echo "<head>\n ";
echo "<title>\n";
echo "留言添加模块后台处理\n ";
echo "</title>\n";
echo "</head>\n";
echo "<body>\n";
if(!$_POST[username] || !$_POST[content]) //如果没有用户名或者留言内容
{
echo "<meta http-equiv=\"refresh\" content=\"2; url=14-19.php\">\n";
echo "没有填写的用户名或者留言内容!\n";
echo "<p>\n";
echo "两秒后返回提交前台\n";
exit(); //中止所有PHP代码
}
else //如果存在相应内容
{
$re_id=$_POST[re_id]; //获取回复ID
include "14-16.php";
$sql="SELECT re_id FROM $t_name WHERE id='$re_id'";
$tem=mysql_fetch_row(mysql_query($sql,$my_conn));
if($tem[0]!=0) //如果回复的留言不是主留言
{
echo "<meta http-equiv=\"refresh\" content=\"2; url=14-18.php\">\n";
echo "所回复的留言不是主留言!\n";
echo "<p>\n";
echo "两秒后返回显示留言页面\n";
exit(); //中止所有PHP代码
}
else
{
$username=htmlspecialchars($_POST[username]);//获取用户名
if($_POST[title]) //如果有标题
{
$title=htmlspecialchars($_POST[title]); //获取用户名
}
else //如果没有标题
{
$title="无标题"; //定义标题
}
$content=htmlspecialchars($_POST[content]); //获取内容,并转换换行符
$content=ereg_replace(" "," ",$content); //转换空格
$content=nl2br($content); //转换回车换行符
$face=$_POST[face]; //获取表情
$time=date("Y-m-d H:i:s"); //获取留言时间
if($re_id!=0) //如果是回复留言
{
$re_time=""; //则本条留言回复时间为空
}
else //如果为发表新留言
{
$re_time=$time; //回复时间为发表留言时间
}
$sql="insert into $t_name(username,title,content,re_id,face,time,re_time,re_num) values ('$username','$title','$content','$re_id','$face','$time','$re_time','0')";
$result=mysql_query($sql,$my_conn) or die(mysql_error());
if($re_id!=0)
{
$strSql="update $t_name set re_time='$time',re_num=re_num+1 where id='$re_id'";
$result=mysql_query($strSql,$my_conn) or die(mysql_error());
}
echo "<meta http-equiv=\"refresh\" content=\"2; url=14-18.php\">\n";
echo "提交留言成功!\n";
echo "<p>\n";
echo "两秒后返回留言首页\n";
}
}
echo "<body>\n";
echo "<html>\n";
?>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -