亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

PHP開發(fā) 小型論壇教程之發(fā)布新帖-2

創(chuàng)建addnew_post.php 文件

本頁(yè)面主要是處理從發(fā)布頁(yè)面addnew.php傳過(guò)來(lái)的數(shù)據(jù),然后在進(jìn)行數(shù)據(jù)庫(kù)存入

11.jpg

代碼如下

<?php
header("Content-type:text/html;charset=utf-8");    //設(shè)置編碼
$servername = "localhost";
$username = "root";
$password = "root";
$dbname = "mybbs";
// 創(chuàng)建連接
$conn = mysqli_connect($servername, $username, $password, $dbname);
mysqli_set_charset($conn,'utf8'); //設(shè)定字符集
$author=$_POST['author'];
//print_r($author);
//die;
$title=$_POST['title'];
$content=$_POST['content'];
$last_post_time=date("Y-m-d H:i:s");
$sql="insert into tiopic(author,title,content,last_post_time) values('$author','$title','$content','$last_post_time')";
$que=mysqli_query($conn,$sql);
if($que){
    echo "<script>alert('發(fā)布成功');location.href='forums.php';</script>";
}else{
    echo "<script>alert('好像有點(diǎn)小問(wèn)題......');location.href='addnew.php';</script>";
}
?>


繼續(xù)學(xué)習(xí)
||
<?php header("Content-type:text/html;charset=utf-8"); //設(shè)置編碼 $servername = "localhost"; $username = "root"; $password = "root"; $dbname = "mybbs"; // 創(chuàng)建連接 $conn = mysqli_connect($servername, $username, $password, $dbname); mysqli_set_charset($conn,'utf8'); //設(shè)定字符集 $author=$_POST['author']; //print_r($author); //die; $title=$_POST['title']; $content=$_POST['content']; $last_post_time=date("Y-m-d H:i:s"); $sql="insert into tiopic(author,title,content,last_post_time) values('$author','$title','$content','$last_post_time')"; $que=mysqli_query($conn,$sql); if($que){ echo "<script>alert('發(fā)布成功');location.href='forums.php';</script>"; }else{ echo "<script>alert('好像有點(diǎn)小問(wèn)題......');location.href='addnew.php';</script>"; } ?>
提交重置代碼