欧美一区二区三区老妇人-欧美做爰猛烈大尺度电-99久久夜色精品国产亚洲a-亚洲福利视频一区二区

php數據庫留言,php留言板模板

php需用戶登錄數據庫的留言板

首先呢,你這樣的思路是錯誤的,普通的用戶怎么能允許他登陸到數據庫呢。

創(chuàng)新互聯(lián)是一家專業(yè)提供平川企業(yè)網站建設,專注與成都網站設計、成都做網站、html5、小程序制作等業(yè)務。10年已為平川眾多企業(yè)、政府機構等服務。創(chuàng)新互聯(lián)專業(yè)網站設計公司優(yōu)惠進行中。

再者,這個留言板你要是開發(fā)賣給其他的客戶,可以做成安裝版,你可能接觸過一些cms,就是安裝的時候,選擇讓用戶設置本地的數據庫密碼,這樣就實現(xiàn)了你想要的效果。

php怎么在mysql創(chuàng)建留言板步驟

工具:

Dreamweaver

php、mysql服務器

步驟/方法

首先是確定自己的留言板需求.例如:名字,郵件及留言內容.

一. 建立一個數據庫guestbook。

CREATE TABLE IF NOT EXISTS `content` (

`id` int(11) NOT NULL auto_increment,

`name` varchar(20) NOT NULL,

`email` varchar(50) NOT NULL,

`content` varchar(200) NOT NULL,

PRIMARY KEY (`id`))

ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=3;

二. 新建config.php

? php

$q = mysql_connect("服務器","數據庫用戶","數據庫密碼");

if(!$q)

{

die('Could not connect: ' . mysql_error());

}

mysql_query("set names utf8"); //以utf8讀取數據

mysql_select_db("guestbook",$q); //數據庫

?

三. 新建index.php

?php

include("config.php"); //引入數據庫連接文件

$sql = "select * from content"; //搜索數據表content

$resule = mysql_query($sql,$q);

?

html

meta http-equiv="Content-Type" content="text/html; charset=utf-8" /

body

table width="678" align="center"

tr

td colspan="2" h1留言本 /h1 /td

/tr

tr

td width="586" a href="index.php"首頁 /a | a href="liuyan.php"留言 /a /td

/tr

/table

p

?

while($row=mysql_fetch_array($resule))

{

?

/p

table width="678" border="1" align="center" cellpadding="1" cellspacing="1"

tr

td width="178"Name: ? echo $row[1] ? /td

td width="223"Email: ? echo $row[2] ? /td

/tr

tr

td colspan="4" ? echo $row[3] ? /td

/tr

tr

/table

?

}

?

/body

/html

四. 新建liuyan.php

html

body

meta http-equiv="Content-Type" content="text/html; charset=utf-8" /

table width="678" align="center"

tr

td colspan="2" h1留言本 /h1 /td

/tr

tr

td width="586" a href="index.php"首頁 /a | a href="liuyan.php"留言 /a /td

/tr

/table

table align="center" width="678"

tr

td

form name="form1" method="post" action="post.php"

p

Name:

input name="name" type="text" id="name"

/p

pEmail: input type="test" name="email" id="email" /p

p

留言:

/p

p

textarea name="content" id="content" cols="45" rows="5" /textarea

/p

p

input type="submit" name="button" id="button" value="提交"

input type="reset" name="button2" id="button2" value="重置"

/p

/form

/td

/tr

/table

/body

/html

五. 新建post.php

?php

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

include("config.php");

$name= $_POST['name'];

$email= $_POST['email'];

$patch = $_POST['content'];

$content = str_replace("

"," br /",$patch);

$sql = "insert into content (name,email,content) values ('$name','$email','$content')";

mysql_query($sql);

echo " scriptalert('提交成功!返回首頁。');location.href='index.php'; /script";

?

這樣已經成功的寫出一個留言板了。

第二部分

此次將在上面版本上加多管理,回復等功能。

首先在sql中字節(jié)。

ALTER TABLE `content` ADD `reply` VARCHAR( 200 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL AFTER `content`

一. 新建login.php

html xmlns=""

meta http-equiv="Content-Type" content="text/html; charset=utf-8" /

title無標題文檔 /title

/head

body table width="678" align="center"

tr

td colspan="2" h1留言本 /h1 /td

/tr

tr

td width="586" a href="index.php"首頁 /a | a href="liuyan.php"留言 /a /td

/tr

/table

table align="center" width="678"

tr

td align="center"

form name="form1" method="post" action="login2.php"

label for="textfield" /label

p /p

p帳號:

input type="text" name="name" id="name"

/p

p密碼:

input type="password" name="pw" id="pw"

/p

p

input type="submit" name="button" id="button" value="提交"

input type="reset" name="button2" id="button2" value="重置"

/p

/form /td

/tr

/table

/body

/html

二.login2.php

?

session_start();

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

$name = $_POST['name'];

$pw = $_POST['pw'];

if($name == "admin" $pw == "admin"){

$_SESSION["adminname"] = $name;

echo " scriptalert('登錄完成,返回首頁!');location.href='index.php'; /script";

}else{

echo " scriptalert('錯誤!');location.href='login.php'; /script";

}

?

三. 在原有的index.php上添加

?php

session_start();

include("config.php");

$sql = "select * from content";

$resule = mysql_query($sql,$q);

?

html

meta http-equiv="Content-Type" content="text/html; charset=utf-8" /

body

table width="678" align="center"

tr

td colspan="2" h1留言本 /h1 /td

/tr

tr

td width="586" a href="index.php"首頁 /a | a href="liuyan.php"留言 /a /td

td width="80"

// 新增管理員登錄

?php

if (isset($_SESSION['adminname']) $_SESSION["adminname"] == "admin"){

echo " a href='logout.php'登出 /a";

}else{

echo " a href='login.php'管理員登錄 /a";

}

?

/td

/tr

/table

p

?

while($row=mysql_fetch_array($resule))

{

?

/p

table width="678" border="1" align="center" cellpadding="1" cellspacing="1"

tr

td width="178"Name: ? echo $row[1] ? /td

td width="223"Email: ? echo $row[2] ? /td

td width="100"

?php

if(isset($_SESSION['adminname']) $_SESSION["adminname"] == "admin"){

echo " a href='huifu.php?id=" . $row[0] . "'回復 /a";

echo " | " . " a href='delete.php?id=" . $row[0] . "'刪除 /a";

} else {

echo "";

}

?

/td

/tr

tr

td colspan="4" ? echo $row[3] ? /td

/tr

tr

td colspan="4" ?

if($row[4] == ""){

?

? echo "暫無回復。";?

? }else {echo "管理員回復:". $row[4]; } ? /td

/tr

/table

?

}

?

/body

/html

四. 新建huifu.php

?php

include("config.php");

$sql = "select * from content where id=".$_GET["id"];

$resule = mysql_query($sql,$q);

SetCookie("id",$_GET["id"]);

session_start();

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

if(empty($_SESSION["adminname"])){

exit(" script language='javascript'alert('您尚未登錄后臺,或登錄已超時,請重新登錄!');window.location.href='login.php'; /script");

}

?

!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" ""

html xmlns=""

head

meta http-equiv="Content-Type" content="text/html; charset=utf-8" /

title無標題文檔 /title

/head

body

table width="678" align="center"

tr

td colspan="2" h1留言本 /h1 /td

/tr

tr

td width="586" a href="index.php"首頁 /a | a href="liuyan.php"留言 /a /td

/tr

/table

table align="center" width="678"

tr

td

form name="reply" method="post" action="reply.php"

p回復:

?

while($row=mysql_fetch_array($resule))

{

echo $row[3];

}

?

/p

p

textarea name="reply" id="reply" cols="45" rows="5" /textarea

/p

p

input type="submit" name="button" id="button" value="回復" /

input type="reset" name="button2" id="button2" value="重置" /

/p

/form

/td

/tr

/table

/body

/html

五. reply.php 回復留言提交頁面.

?

include("config.php");

$id = $_COOKIE["id"];

$sql = "select * from content";

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

$patch = $_POST["reply"];

$reply = str_replace("

"," br /",$patch);

$resule = mysql_query("UPDATE `2`.`content` SET `reply` = '$reply' WHERE `content`.`id` ="."$id");

echo " scriptalert('回復成功!');location.href='index.php'; /script";

?

這樣就可以建立出一個簡單的管理.管理帳號都是admin 因為只是判別輸入的是不是admin 是的話就把值輸入進session中.

用PHP怎么做留言板

我來教你:

首先你要建立一個mysql數據庫

然后在數據庫里面設置字段 例如 用戶 留言

當你在html頁面的文本框填寫留言后,用表單點擊提交(在表單里面要設置提交到那個頁面 比如:index.php)

當你提交到改頁面后,在這個頁面填寫你的php代碼

就是連接數據庫,然后將你的留言寫進數據庫

最后查看 和刪除 就是執(zhí)行數據庫常見的查詢功能和刪除功能了

本文題目:php數據庫留言,php留言板模板
文章分享:http://chinadenli.net/article30/dsephso.html

成都網站建設公司_創(chuàng)新互聯(lián),為您提供微信小程序云服務器Google品牌網站設計全網營銷推廣

廣告

聲明:本網站發(fā)布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經允許不得轉載,或轉載時需注明來源: 創(chuàng)新互聯(lián)

網站托管運營