Add processing page in the background after PHP development article publishing system
Article adding processing page
The adding processing flow chart is as follows:
The code is as follows:
<?php require_once("../connect.php"); //把傳遞過來的信息入庫,在入庫之前對所有的信息進行校驗。 if(!(isset($_POST['title'])&&(!empty($_POST['title'])))){ echo "<script>alert('標題不能為空');history.go(-1);</script>"; } $title = $_POST['title']; $author = $_POST['author']; $description = $_POST['description']; $content = $_POST['content']; $dateline = time(); $insertsql = "insert into article(title, author, description, content, dateline) values('$title', '$author', '$description', '$content', $dateline)"; //echo $insertsql; //exit; if(mysqli_query($conn,$insertsql)){ echo "<script>alert('發(fā)布文章成功');window.location.href='admin_manage.php';</script>"; }else{ echo "<script>alert('發(fā)布失敗');history.go(-1);</script>"; } ?>
Code explanation
First introduce the file to connect to the database, connect to the database
Determine whether the title has been passed through the post method, if not, it will prompt that the title cannot be empty , return to the previous page, and continue if necessary
Get all the values ??passed in the post method, and use the timestamp method to obtain the time
Insert the obtained data into the database to determine whether it is successful. If it is not successful, it will prompt that the publication failed and return to the add page. If it is successful, it will jump to the article management page