PHP development...LOGIN

PHP development small forum tutorial - adding forum-2

This page is used to process the data submitted from the add page form

2.jpg

The code is as follows

<?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>";
}
?>

Now we can add the forum, you You might as well add a forum and go to the homepage to have a look


As we said before, if the user is not logged in, we are not allowed to post and add the forum, so next we need to log in and register. page


Next Section
<?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>"; } ?>
submitReset Code
ChapterCourseware