偶的第乙個PHP成品 留言板

2021-06-16 06:11:11 字數 3270 閱讀 3343

第二位感謝的就是偶同事了,幫我解決了好幾個問題。下面偶把程式貼出來哩 雖然98%是抄上面那位大俠的,留作紀念!

包括:儲存的資料庫:gbook

input.html為初始頁

insert.php為把輸入內容送入資料庫

建立資料庫:

create database gbook;

create table `gbook` (

`id` int( 255 ) unsigned not null auto_increment primary key ,

`name` varchar( 10 ) not null ,

`***` tinyint( 1 ) unsigned not null ,

`email` varchar( 255 ) not null ,

`info` text not null ,

`ip` varchar( 15 ) not null ,

`time_at` datetime not null

)

input.html:

insert.php:

<?php

header("content-type:text/html; charset=utf-8");

$mysql_server_name="localhost";

$mysql_username="root";

$mysql_password="123456";

$mysql_database="gbook";

$name=$_post[name];

$***=$_post[***];

$email=$_post[email];

$info=$_post[info];

$ip=getenv('remote_addr');

$conn=mysql_connect("localhost","root","123456");

show.php:

">

">

<?php

$mysql_server_name="localhost";

$mysql_username="root";

$mysql_password="123456";

$mysql_database="gbook";

$sql="select*from gbook order by id desc";

$conn=mysql_connect($mysql_server_name,$mysql_username,$mysql_password);

mysql_select_db($mysql_database,$conn);

$result=mysql_query($sql);

while($row=mysql_fetch_row($result))

if($row[2]==0)

$gender='女';

?>

<?=$row[6]?><?=$row[5]?>

<?=$row[1]?>(<?=$gender?>)<?=$row[3]?>

<?=nl2br($row[4])?>">[修改]

">[刪除]

<?   

}mysql_free_result($result);

?>

change.php:

">

<?

$id = $_get['id'];

change_ok.php:

">

">

<?

$id = $_get['id'];

$mysql_server_name="localhost";

$mysql_username="root";

$mysql_password="123456";

$mysql_database="gbook";

$name=$_post[name];

$***=$_post[***];

$email=$_post[email];

$info=$_post[info];

$sql="update `gbook` set `name`='$name', `***`='$***',`email`='$email',`info`='$info' where `id`='$id'";

$conn=mysql_connect($mysql_server_name,$mysql_username,$mysql_password);

mysql_select_db($mysql_database,$conn);

$result=mysql_query($sql);

mysql_close($conn);

?>返回

del.php:

">

">

<?

$id = $_get['id'];

$mysql_server_name="localhost";

$mysql_username="root";

$mysql_password="123456";

$mysql_database="gbook";

$sql="delete from gbook where id='$id'";

$conn=mysql_connect($mysql_server_name,$mysql_username,$mysql_password);

mysql_select_db($mysql_database,$conn);

$result=mysql_query($sql);

mysql_close($conn);

?>

[返回]

程式參考:

乙個簡單的PHP留言板

如果你已經有一定程式設計基礎請自行出門左轉 接下來我們就直接開始。首先構建乙個進入的主頁面 這是首頁 此處混編 接下來就是書提交到資料庫,此處對資料進行驗證一下,看是否提交了空資料 展示介面就是將已經寫好的資料,從資料庫中迴圈出來即可。include conn.php perpagenum 5 定義...

php留言板入門教程,乙個php留言板例項

1.在你的php的根目錄下建立乙個名為 msgboard 的資料夾.在 msgboard 下建立乙個 msglist.php 檔案,資料表結構大家可直接匯入。例項 如下 create table msgboard id int 10 not null auto increment,username ...

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

1.資料庫建立乙個message表用來儲存資料 2.連線資料庫 我是原生代pdo host 127.0.0.1 port 3306 埠 username root 使用者名稱 password root 密碼 dbname 表名 dsn mysql dbname dbname host host 拼...