PHP+MYSQL留言板代码Word文档格式.docx

上传人:b****7 文档编号:22028078 上传时间:2023-02-02 格式:DOCX 页数:15 大小:18.26KB
下载 相关 举报
PHP+MYSQL留言板代码Word文档格式.docx_第1页
第1页 / 共15页
PHP+MYSQL留言板代码Word文档格式.docx_第2页
第2页 / 共15页
PHP+MYSQL留言板代码Word文档格式.docx_第3页
第3页 / 共15页
PHP+MYSQL留言板代码Word文档格式.docx_第4页
第4页 / 共15页
PHP+MYSQL留言板代码Word文档格式.docx_第5页
第5页 / 共15页
点击查看更多>>
下载资源
资源描述

PHP+MYSQL留言板代码Word文档格式.docx

《PHP+MYSQL留言板代码Word文档格式.docx》由会员分享,可在线阅读,更多相关《PHP+MYSQL留言板代码Word文档格式.docx(15页珍藏版)》请在冰豆网上搜索。

PHP+MYSQL留言板代码Word文档格式.docx

/title>

/head>

linkhref="

css.css"

rel="

stylesheet"

type="

text/css"

body>

divid="

head"

<

head_l"

ul>

li>

ahref="

index.php"

偶要看留言<

/a>

/li>

post.php"

偶要发表<

session_start();

if($_SESSION["

key"

]==1){//如果获取的SESSION为1则显示管理项

?

adminexit.php"

退出管理<

}

else

{

admin.php"

偶要管理<

}?

/ul>

/div>

head_r"

3、footer.php(公用底部文件)

$counterFile="

conter.xml"

;

functiondisplayCounter($counterFile){

$fp=fopen($counterFile,"

rw"

$num=fgets($fp,5);

$num+=1;

print"

divid=\"

footer\"

银子留言板Version1.0&

nbsp;

&

您是第&

."

$num"

位无聊的银<

exec("

rm-rf$counterFile"

echo$num>

$counterFile"

}

if(!

file_exists($counterFile)){

echo0>

displayCounter($counterFile);

/body>

/html>

4、index.php(首页)

require_once("

conn.php"

header.php"

session_start();

//分页代码开始

$pagesize=10;

//设置每页显示条数

$rs=mysql_query("

selectcount(*)fromlo"

//取得记录总数,计算总页数用

$myrow=mysql_fetch_array($rs);

$numrows=$myrow[0];

//计算总记录

$pages=intval($numrows/$pagesize);

if($numrows%$pagesize)$pages++;

//设置页数

if(isset($_GET['

page'

]))

$page=intval($_GET['

]);

$page=1;

//设为第一页

$offset=$pagesize*($page-1);

//计算记录偏移量

//分页代码结束

$sql="

selectid,username,sex,qq,email,info,ip,DATE_FORMAT(submit_time,'

%Y年%m月%d日%T'

)fromloorderbyiddesclimit$offset,$pagesize"

//用到了DATE-FORMAT格式化日期格式

$result=mysql_query($sql);

$num=mysql_num_rows($result);

if($num>

0){

while($row=mysql_fetch_array($result))

//echoprint_r($row);

if($row[2]=="

男"

)//这个使性别改成你想要的名称^_^

$sex="

帅锅"

美女"

show"

pclass="

num"

第[<

=$row[0]?

]条留言<

p>

unline"

留言人:

spanclass="

blue"

=$row[1]?

/span>

性别:

=$sex?

留言时间:

=$row[7]?

if($row[3]){?

$row[3]?

Site=&

Menu=yes"

imgsrc="

img/qq.gif"

alt="

=$row[3]?

}?

if($row[4]){?

mailto:

=$row[4]?

img/email.gif"

=$row[4]?

}?

]==1){?

IP:

=$row[6]?

update.php?

wuleying&

id=<

=$row[0]?

更改<

delete.php?

删除<

/p>

留言内容:

show_info"

=nl2br(htmlspecialchars($row[5]))?

else

echo"

show\"

无数据......<

show_page"

$first=1;

$prev=$page-1;

$next=$page+1;

$last=$pages;

if($page==1&

$pages>

1)

{

首页&

|&

上一页&

ahref=\"

index.php?

page="

.$next."

\"

下一页<

.$last."

尾页<

elseif($page>

=1&

$page!

=$pages&

$num>

0)

.$first."

首页<

.$prev."

上一页<

elseif($page==$pages&

=1)

下一页&

尾页&

elseif($page==$pages)

共&

span>

=$pages?

页&

当前第&

=$page?

=$numrows?

nbsp条留言<

mysql_close();

footer.php"

5、post.php(提交留言页面)

input"

formmethod="

post"

action="

input.php"

name="

form1"

h1>

提交留言<

/h1>

姓名:

inputtype="

text"

name"

size="

20"

class="

y"

性别:

inputname="

sex"

radio"

value="

checked/>

帅锅&

女"

/>

美女<

QQ :

qq"

(可选填)<

Email:

email"

留言内容:

textareaname="

info"

rows="

5"

cols="

40"

/textarea>

cen"

submit"

偶填好了"

reset"

偶要重写"

cen1"

/form>

6、input.php(插入留言)

$username=$_POST['

name'

];

$sex=$_POST['

sex'

$qq=$_POST['

qq'

$email=$_POST['

email'

$info=$_POST['

info'

if(strrpos($username,"

)!

==false||strrpos($username,"

==false||strrpos($username,"

@"

'

_"

==false)

script>

alert('

名称不能有特殊字符!

location.href='

post.php'

/script>

exit();

if(!

ereg("

^[0-9]{0,}$"

$qq))//用正则检查QQ格式

OICQ信息有错误!

必须是数字!

if($email)

{//如果填写了邮箱就用正则检查邮箱格式

if(!

^[a-zA-Z0-9_\-\.]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-\.]+$"

$email))

email格式不正确!

$username)

名称不能为空哦!

elseif(!

$info)

留言不能为空哦!

$ip=getenv('

REMOTE_ADDR'

//获取客户端IP地址

$sql="

insertintolo(username,sex,qq,email,info,ip,submit_time)values('

$username'

'

$sex'

$qq'

$email'

$info'

$ip'

NOW())"

$result=mysql_query($sql);

mysql_close();

提交成功!

返回首页'

index.php'

7、update.php(修改留言页)

require_once('

conn.php'

header.php'

if($_SESSION["

]==1)

$id=$_GET['

id'

select*fromlowhereid="

.$id;

$row=mysql_fetch_array($result);

update"

formaction="

updatepost.php?

method="

修改留言<

姓名:

/input>

留言:

35"

=$row[5]?

偶要修改"

div>

header('

location:

8、updatepost(修改提交页)

//echo$id;

updatelosetusername='

.$username."

info='

.$info."

whereid="

mysql_query($sql);

echo"

修改成功!

9、delete.php(删除留言页)

$id=$_GET['

deletefromlowhereid="

10、admin.php(管理登录页)

admin"

adminpost.php"

管理员登录<

姓名:

密码:

password"

管理员登录"

11、adminpost.php(管理验证页)

$name=$_POST['

$password=$_POST['

password'

select*fromadminwherename='

.$name."

if(strrpos($name,"

==false||strrpos($name,"

==false||strrpos($name,"

不能有特殊字符!

admin.php'

if($num)

{//如果用户存在,就检查密码是否正确

$rs=mysql_fetch_array($result);

if($rs[2]!

=$password)

密码不正确,请确认后输入!

{//用户名,密码都正确,注册SESSION变量,然后跳转到首页

$_SESSION["

]=1;

登录成功!

{//如果没有这个用户

没有这个用户,请确认后输入!

12、adminexit.php(退出管理页)

$_SESSION["

]=0;

//使SESSION不为1,0为游客,1为管理员

只是些基本的东东,像MD5加密,UBB,表情图片,添加管理员账号,回复留言(-_!

)等我都没加上去,有兴趣的同学可以完善下,不足的地方请指出^_^

管理员账号:

wuleying密码:

123456

文章来源:

侠客站长站()详文参考:

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 高等教育 > 艺术

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1