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

php連接數(shù)據(jù)庫(kù)的留言板,php無(wú)數(shù)據(jù)庫(kù)留言板

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

工具:

創(chuàng)新互聯(lián)公司是一家專注于成都網(wǎng)站建設(shè)、成都做網(wǎng)站與策劃設(shè)計(jì),江都網(wǎng)站建設(shè)哪家好?創(chuàng)新互聯(lián)公司做網(wǎng)站,專注于網(wǎng)站建設(shè)10年,網(wǎng)設(shè)計(jì)領(lǐng)域的專業(yè)建站公司;建站業(yè)務(wù)涵蓋:江都等地區(qū)。江都做網(wǎng)站價(jià)格咨詢:18982081108

Dreamweaver

php、mysql服務(wù)器

步驟/方法

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

一. 建立一個(gè)數(shù)據(jù)庫(kù)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("服務(wù)器","數(shù)據(jù)庫(kù)用戶","數(shù)據(jù)庫(kù)密碼");

if(!$q)

{

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

}

mysql_query("set names utf8"); //以u(píng)tf8讀取數(shù)據(jù)

mysql_select_db("guestbook",$q); //數(shù)據(jù)庫(kù)

?

三. 新建index.php

?php

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

$sql = "select * from content"; //搜索數(shù)據(jù)表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"首頁(yè) /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"首頁(yè) /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('提交成功!返回首頁(yè)。');location.href='index.php'; /script";

?

這樣已經(jīng)成功的寫出一個(gè)留言板了。

第二部分

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

首先在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無(wú)標(biāo)題文檔 /title

/head

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

tr

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

/tr

tr

td width="586" a href="index.php"首頁(yè) /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帳號(hào):

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('登錄完成,返回首頁(yè)!');location.href='index.php'; /script";

}else{

echo " scriptalert('錯(cuò)誤!');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"首頁(yè) /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] . "'回復(fù) /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 "暫無(wú)回復(fù)。";?

? }else {echo "管理員回復(fù):". $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('您尚未登錄后臺(tái),或登錄已超時(shí),請(qǐng)重新登錄!');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無(wú)標(biāo)題文檔 /title

/head

body

table width="678" align="center"

tr

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

/tr

tr

td width="586" a href="index.php"首頁(yè) /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回復(fù):

?

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="回復(fù)" /

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

/p

/form

/td

/tr

/table

/body

/html

五. reply.php 回復(fù)留言提交頁(yè)面.

?

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('回復(fù)成功!');location.href='index.php'; /script";

?

這樣就可以建立出一個(gè)簡(jiǎn)單的管理.管理帳號(hào)都是admin 因?yàn)橹皇桥袆e輸入的是不是admin 是的話就把值輸入進(jìn)session中.

php留言板源碼怎么連接已有的mysql數(shù)據(jù)庫(kù)

" "號(hào)中間填寫所需

$shujuku="data"; //數(shù)據(jù)庫(kù)名稱

$yonghu="root"; //數(shù)據(jù)庫(kù)用戶名

$mima=""; //數(shù)據(jù)庫(kù)密碼

mysql_query("SET NAME 'GB2312'"); //這個(gè)是強(qiáng)制編碼,如果你的php是utf-8的就寫utf8

如果是gbk的不管

你可以再mysql_query("SET NAME ‘GB2312’")下面加入

echo "連接成功"; //如果出現(xiàn)這個(gè),證明連接成功了。、

當(dāng)然,如果你不加,直接運(yùn)行上面的連接頁(yè)面,如果是空白,證明也是連接成功的

php需用戶登錄數(shù)據(jù)庫(kù)的留言板

首先呢,你這樣的思路是錯(cuò)誤的,普通的用戶怎么能允許他登陸到數(shù)據(jù)庫(kù)呢。

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

分享題目:php連接數(shù)據(jù)庫(kù)的留言板,php無(wú)數(shù)據(jù)庫(kù)留言板
文章URL:http://chinadenli.net/article34/dsgjcse.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站制作網(wǎng)站排名外貿(mào)網(wǎng)站建設(shè)云服務(wù)器電子商務(wù)全網(wǎng)營(yíng)銷推廣

廣告

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

網(wǎng)站建設(shè)網(wǎng)站維護(hù)公司