本頁面是處理從新增頁面表單提交過來的資料
#程式碼如下
<?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>"; } ?>
現在我們可以新增論壇了,你不妨加入一個論壇再到首頁去看看
我們前面說了,用戶如果在沒有登入的情況了,我們是不允許發布添加論壇的,所以,下面我們要做登入註冊頁面