PHP留言板 一看就會的留言板

2021-10-10 11:49:52 字數 929 閱讀 3116

1.資料庫建立乙個message表用來儲存資料

2.連線資料庫 (我是原生代pdo

$host = "127.0.0.1";//

$port = "3306"; //埠

$username = "root";//使用者名稱

$password = "root";//密碼

$dbname = "";//表名

$dsn = "mysql:dbname=$dbname;host=$host";//拼接

$pdo = new pdo($dsn, $username, $password);//例項化pdo

3.提交頁面

//引入pdo連線資料庫

require "pdo.php";

//提交判斷

if($_post)else

if($row1)

}

//引入pdo連線資料庫

require "pdo.php";

$message = $pdo->query('select user,title,content from message');

$row = $message->fetchall(pdo::fetch_assoc);

/*echo "";print_r($row);echo "";*/

//遍歷陣列

foreach ($row as $k => $v);

PHP製作留言板

首先造乙個登入頁面 上圖 然後來寫處理頁面 session start session儲存資料 include db.class.php 引用類 db new db 造方法 zhang post zhang mi post mi sql select mi from yuangong where z...

PHP 留言板練習

登入頁面同session一樣 login頁面 loginchuli頁面 session start uid post uid pwd post pwd include dbda.php db new dbda sql select count from yuangong where username...

php製作留言板的題 PHP如何實現留言板功能

首先建立訊息表,其主要欄位有傳送者的名稱,訊息內容,以及訊息傳送時間 sql create table guanhui message id int 10 not null auto increment comment 訊息id sender varchar 60 not null comment ...