post.php
<?php
ob_start();
include("db_conn.php"); // 匯入資料庫訊息
// 接收從 index.php 傳送的資料
$author = $_POST['author'];
$email = $_POST['email'];
$content = $_POST['content'];
$date = date("Y-m-d"); // 產生留言的日期
$sql = "INSERT INTO guestbook_tab (gb_name,gb_msg,gb_date,gb_email)";
$sql .= "VALUES ('$author','$content','$date','$email')";
echo $sql;
mysql_query("SET NAMES utf8"); // 強制為 utf-8 編碼
mysql_query($sql);
mysql_close($conn);
header("location:index.php"); // 回首頁 (index.php)
exit(); // 離開程式
?> |