留言板.docx

上传人:b****4 文档编号:4273417 上传时间:2023-05-06 格式:DOCX 页数:11 大小:17.91KB
下载 相关 举报
留言板.docx_第1页
第1页 / 共11页
留言板.docx_第2页
第2页 / 共11页
留言板.docx_第3页
第3页 / 共11页
留言板.docx_第4页
第4页 / 共11页
留言板.docx_第5页
第5页 / 共11页
留言板.docx_第6页
第6页 / 共11页
留言板.docx_第7页
第7页 / 共11页
留言板.docx_第8页
第8页 / 共11页
留言板.docx_第9页
第9页 / 共11页
留言板.docx_第10页
第10页 / 共11页
留言板.docx_第11页
第11页 / 共11页
亲,该文档总共11页,全部预览完了,如果喜欢就下载吧!
下载资源
资源描述

留言板.docx

《留言板.docx》由会员分享,可在线阅读,更多相关《留言板.docx(11页珍藏版)》请在冰点文库上搜索。

留言板.docx

留言板

数据库结构:

(库名:

lyb)

表一:

admin

字段:

id(int11)  name(varchvr)  password(varchvr)

表二:

lo

字段:

id(int11)  username(varchvr) sex(varchvr) qq(varchvr) email(varchvr) info(text) ip(varchvr) submit_time(datetime)

1、conn.php(连接数据库文件)

php

mysql_connect("localhost","root","");//连接数据库

mysql_select_db("lyb");//选择数据库

?

>

2、header.php(公用头部文件)

DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN""http:

//www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

//www.w3.org/1999/xhtml">

银子留言板Version1.0

  • 偶要看留言
  • 偶要发表
  • php

    session_start();

    if($_SESSION["key"]==1){//如果获取的SESSION为1则显示管理项

    ?

    >

  • 退出管理
  • }

    else

    {

    ?

    >

  • 偶要管理
  • }?

    >

银子留言板Version1.0

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

php

$counterFile="conter.xml";

functiondisplayCounter($counterFile){

$fp = fopen($counterFile,"rw");

$num= fgets($fp,5);

$num+=1;

print"银子留言板Version1.0   您是第 "."$num"." 位无聊的银";

exec("rm-rf$counterFile");

exec("echo$num>$counterFile");

}

if(!

file_exists($counterFile)){

exec("echo0>$counterFile");

}

displayCounter($counterFile);

?

>

4、index.php(首页)

php

require_once("conn.php");

require_once("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']);

}

else

{

$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="帅锅";

}

else

{

$sex="美女";

}

?

>

第[

=$row[0]?

>]条留言

留言人:

=$row[1]?

>  性别:

=$sex?

>  留言时间:

=$row[7]?

if($row[3]){?

>&Site=&Menu=yes">

}?

>

if($row[4]){?

=$row[4]?

>"> 

}?

>

if($_SESSION["key"]==1){?

> IP:

=$row[6]?

>  

wuleying&id=

=$row[0]?

>">更改 

wuleying&id=

=$row[0]?

>">删除

}?

>

留言内容:

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

>

php

}

}

else

{

echo"无数据......";

}

?

>

php

$first=1;

$prev=$page-1;

$next=$page+1;

$last=$pages;

if($page==1&&$pages>1)

{

echo"首页 | ";

echo"上一页 | ";

echo"

page=".$next."\">下一页 | ";

echo"

page=".$last."\">尾页 | ";

}

elseif($page>=1&&$page!

=$pages&&$num>0)

{

echo"

page=".$first."\">首页 | ";

echo"

page=".$prev."\">上一页 | ";

echo"

page=".$next."\">下一页 | ";

echo"

page=".$last."\">尾页 | ";

}

elseif($page==$pages&&$page!

=1)

{

echo"

page=".$first."\">首页 | ";

echo"

page=".$prev."\">上一页 | ";

echo"下一页 | ";

echo"尾页 | ";

}

elseif($page==$pages)

{

echo"首页 | ";

echo"上一页 | ";

echo"下一页 | ";

echo"尾页 | ";    

}

else

{

echo"首页 | ";

echo"上一页 | ";

echo"下一页 | ";

echo"尾页 | ";

}

?

>

共 

=$pages?

> 页 | 当前第 

=$page?

> 页 | 共 

=$numrows?

> 条留言

php

mysql_close();

?

>

php

require_once("footer.php");

?

>

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

require_once("header.php");

?

>

提交留言

姓名:

 

性别:

 帅锅  美女

QQ :

 (可选填)

Email:

 (可选填)

留言内容:

银子留言板Version1.0

6、input.php(插入留言)

php

require_once("conn.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||strrpos($username,"\"")!

==false||strrpos($username,"'")!

==false||strrpos($username,"_")!

==false)

{

echo"";

exit();

}

if($email)

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

if(!

ereg("^[a-zA-Z0-9_\-\.]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-\.]+$",$email))

{

echo"";

exit();

}

}

if(!

$username)

{

echo"";

}

else

{

header('location:

index.php');

}

?

>

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

php

require_once('conn.php');

require_once('header.php');

?

>

管理员登录

姓名:

 

密码:

 

银子留言板Version1.0

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

php

session_start();

require_once('conn.php');

$name=$_POST['name'];

$password=$_POST['password'];

$sql="select*fromadminwherename='".$name."'";

$result=mysql_query($sql);

$num=mysql_num_rows($result);

if(strrpos($name,"<")!

==false||strrpos($name,">")!

==false||strrpos($name,"@")!

==false||strrpos($name,"\"")!

==false||strrpos($name,"'")!

==false||strrpos($name,"_")!

==false)

{

echo"";

}

else

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

$_SESSION["key"]=1;

echo"";

}

?

>

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

php

session_start();

$_SESSION["key"]=0;//使SESSION不为1,0为游客,1为管理员

header('location:

index.php');

?

>

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

当前位置:首页 > 解决方案 > 学习计划

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2