PHP开发 小型论坛教程之添加论坛-2

创建 save_forum.php 文件

本页面是处理从添加页面add_forum.php提交过来的数据

save.jpg

代码如下

header("content-type:text/html;charset=utf8");
$forum_name=$_POST["forum_name"];
$forum_description=$_POST["forum_description"];
$Subject=$_POST['Subject'];
$time=date("Y-m-d H:i:s");
$conn=mysqli_connect("localhost","root","root","mybbs");
mysqli_set_charset($conn,"utf8");
$sql="insert into  forums (forum_name,forum_description,subject,last_post_time) VALUES ('$forum_name','$forum_description','$Subject','$time')";
$que=mysqli_query($conn,$sql);
if($que){
    echo "<script>alert('添加成功');location.href='index.php';</script>";
}else{
    echo "<script>alert('添加失败,请稍后再试');location.href='add_forum.php';</script>";
}
?>


继续学习
||
<?php header("content-type:text/html;charset=utf8"); $forum_name=$_POST["forum_name"]; $forum_description=$_POST["forum_description"]; $Subject=$_POST['Subject']; $time=date("Y-m-d H:i:s"); $conn=mysqli_connect("localhost","root","root","mybbs"); mysqli_set_charset($conn,"utf8"); $sql="insert into forums (forum_name,forum_description,subject,last_post_time) VALUES ('$forum_name','$forum_description','$Subject','$time')"; $que=mysqli_query($conn,$sql); if($que){ echo "<script>alert('添加成功');location.href='index.php';</script>"; }else{ echo "<script>alert('添加失败,请稍后再试');location.href='add_forum.php';</script>"; } ?>
提交重置代码
关于我们 免责声明 Sitemap
PHP中文网:公益在线PHP培训,帮助PHP学习者快速成长!