php access 留言板程序
发布:smiling 来源: PHP粉丝网 添加日期:2014-09-11 20:45:39 浏览: 评论:0
php access 留言板程序,这里不是php与mysql的留言板程序,而是一款简单实用的php access 留言板程序,利用了adodb来连接access数据库,代码如下:
- error_reporting(0);
- $conn = new com("adodb.connection");
- $conn->open("driver={microsoft access driver (*.mdb)}; dbq=" . realpath("db.mdb "));
- $rs=new com("adodb.recordset");
- $abc = $_get["abc"]; $webn = $_post["webn"]; $name = $_post["name"]; $pws = $_post["pws"]; $newpws = $_post["newpws"];
- $rs->open("select * from [web]",$conn,1,1);
- $adminname = $rs->fields(1)->value;
- $adminpws = $rs->fields(2)->value;
- $ll = $rs->fields(3)->value;
- $webname = $rs->fields(4)->value;
- $rs->close();
- $admincookie = $adminname;
- $conn->execute("update [web] set [ll] = '$ll'+1"); //$rs->close();
- ?>
- <!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">
- <html xmlns="http://www.111cn.net/1999/xhtml">
- <head>
- <meta http-equiv="content-type" content="text/html; charset=gb2312" />
- <title><? echo $webname ?></title>
- <style type="text/css">
- <!--
- body {font-size:14px; line-height:25px; margin:10px auto; padding:10px; width:680px; border:solid #8aa 1px;}
- a {color:#008; text-decoration:none;}
- a:hover {color:#f00; text-decoration:underline;}
- hr {color:#8aa; height:1px;}
- -->
- </style>
- </head>
- <body>
- <?
- if ($abc=="admin"){
- if ($name==$adminname && $pws==$adminpws){
- setcookie("admin", $admincookie, time()+3600); header("location:./");
- }else{echo "<script>alert('用户名或密码错误!');history.back();</script>";}
- }
- if ($abc=="exit"){
- setcookie("admin", "", time()-3600); header("location:./");
- }
- if ($abc=="editadmin"){
- if (!$webname || !$name || !$pws){
- echo "<script>alert('留言本、用户名、原密码不能为空!');history.back();</script>";
- }
- if ($pws!=$adminpws){
- echo "<script>alert('愿密码错误!');history.back();</script>";
- }
- if($newpws!=""){
- $conn->execute("update [web] set [webname] = '$webname' , [name] = '$name' , [pws] = '$newpws'");
- $conn->close(); //$conn=null;
- echo "<script>alert('修改成功,请重新登录!');location='?abc=exit';</script>";
- }else{
- $conn->execute("update [web] set [webname] = '$webn' , [name] = '$name'");
- $conn->close(); //$conn=null;
- echo "<script>alert('修改成功!');location='./';</script>";
- }
- }
- ?>
- <b>【 <a href="./"><? echo $webname ?></a> 】</b>
- <a href="">管理</a> <? if (isset($_cookie["admin"])){ ?> <a href="">修改资料</a> <a href="">安全退出</a><? ;} ?>
- <? if ($abc=="user" && !isset($_cookie["admin"])){ ?>
- <form method="post" action="">
- 用户名:<input name="name" type="text" value=""/>
- 密码:<input name="pws" type="password" value=""/>
- <input name="add" type="submit" value="确定" />
- </form>
- <? ;} ?>
- <? if ($abc=="edituser"){ ?>
- <form method="post" action="">
- 留言本:<input name="webn" type="text" value="<? echo $webname; ?>" size="80"/>
- <br />
- 用户名:<input name="name" type="text" value="<? echo $admincookie; ?>"/>
- 原密码:<input name="pws" type="password" value=""/>
- 新密码:<input name="newpws" type="password" value=""/>
- <input name="add" type="submit" value="确定" />
- </form>
- <? ;} ?>
- <hr/>
- <?
- $id=$_get['id'];
- $sj=date('y-m-d');
- if($abc=="add"){
- $nr=$_post['nr'];
- $ip=getenv("remote_addr");
- if (!$nr){
- echo "<script>alert('留言不能为空!');history.back();</script>";
- }else{
- $conn->execute("insert into [txt] (nr,sj) values ('$nr','$sj')");
- }
- echo "<script>alert('操作成功!');location='./';</script>";
- $conn->close(); $conn=null;
- }
- if($abc=="del"){
- $conn->execute("delete from [txt] where [id]=".$id);
- $conn->close(); $conn=null; header("location:./");
- }
- if($abc=="edit"){
- $nr=$_post['nr'];
- $hf=$_post['hf'];
- $conn->execute("update [txt] set [nr] = '$nr' , [hf] = '$hf' where [id]=".$id);
- $conn->close(); $conn=null; header("location:./");
- }
- $zd=$_get['zd'];
- if($zd!=""){
- if($zd=="0")$zd=1; else $zd=0;
- $conn->execute("update [txt] set [zd] = '$zd' where [id]=".$id);
- $conn->close(); $conn=null; header("location:./");
- }
- ?>
- <center>
- <form method="post" action="">
- <textarea name="nr" cols="88" rows="8" style="line-height:25px;"></textarea><br /><br />
- <input name="add" type="submit" value="发表留言" />
- </form>
- </center>
- <hr/>
- <?
- //分页
- $rs->open("select * from [txt] order by [zd] desc, [sj] desc",$conn,1,3);
- $rs->pagesize=5;
- $page=trim($_get['page']);
- if($page=="" || is_numeric(intval($page))<=0){$page=1;}else if(intval($page)>$rs->pagecount){$page=$rs->pagecount;}
- $page=intval($page);
- if(!$rs->eof||$rs->bof){
- $rs->absolutepage=$page; $mypagesize=$rs->pagesize; $i=$rs->recordcount()-($page-1)*$rs->pagesize;
- while(!$rs->eof && $mypagesize>0 && $i>=$rs->recordcount()-1-$rs->pagesize*$page){
- $id = $rs->fields(0)->value;
- $nr = $rs->fields(1)->value;
- $hf = $rs->fields(2)->value;
- $sj = $rs->fields(3)->value;
- $zd = $rs->fields(4)->value;
- ?>
- <div style="border:#eee solid 1px; background:#f8f8f8; padding:0 10px;">
- <div style="float:left;">
- <? if ($zd!=0) echo "【 <font color='#008800'>置顶</font> 】"; else echo "id.".$i; ?>
- <? if ($_cookie["admin"]==$admincookie){ ?>
- 操作:<a href=''><? if ($zd==0) echo "置顶"; else echo "取消置顶"; ?></a> |
- <a href=''>修改/回复</a> |
- <a href=''>删除</a>
- <? ;} ?>
- </div>
- <div style="float:right;">
- date:<? echo $sj; ?>
- </div>
- <div style="clear:both"></div>
- </div>
- <hr/>
- <? if ($abc=="hf" && $id==$_get['id']){ ?>
- <form method="post" action="" id="<? echo $id ?>">
- 留言:<textarea name="nr" cols="80" rows="8" style="line-height:25px;"><? echo $nr; ?></textarea><br />
- 回复:<textarea name="hf" cols="80" rows="8" style="line-height:25px;"><? echo $hf; ?></textarea><br />
- 操作:<input name="add" type="submit" value="回复/修改" />
- </form>
- <? ;} ?>
- <div style="margin:20px;">
- <?
- $nr = str_replace(" "," ".'<br/>',$nr);
- $nr = str_replace(" ",' ',$nr);
- echo $nr."<br />";
- ?>
- <?
- if ($hf!=""){
- echo "<font color='#aa0000'>回复:";
- $hf = str_replace(" "," ".'<br/>',$hf);
- $hf = str_replace(" ",' ',$hf);
- echo $hf."</font>";
- }
- ?>
- </div>
- <hr/>
- <? $rs->movenext; $mypagesize--; $i--; } } //分页循环 ?>
- <center>
- 留言数(<? echo $rs->recordcount(); ?>)
- <a href="">首页</a>
- <a href="">上页</a>
- 第<? echo $page;?>/<? echo $rs->pagecount;?>页
- <a href="">下页</a>//开源代码phpfensi.com
- <a href="">尾页</a>
- 访问量(<? echo $ll ?>)
- </center>
- <? $rs->close(); $rs=null; $conn->close(); $conn=null; ?>
- </body>
- </html>
数据库结构:
id name pws ll webname
1 abc abc 4 abc 留言本 php+acc
Tags: php access 留言板程序
相关文章
- ·PHP+TEXT留言本(一)(2013-11-11)
- ·PHP+TEXT留言本(二)(2013-11-11)
- ·PHP+TEXT留言本(三)(2013-11-11)
- ·PHP+TEXT留言本(四)(2013-11-11)
- ·PHP+TEXT留言本(五)(2013-11-11)
- ·PHP+TEXT留言本(六)(2013-11-11)
- ·PHP+MYSQL留言本(一)(2013-11-16)
- ·PHP+MYSQL留言本(二)(2013-11-16)
- ·PHP+MYSQL留言本(三)(2013-11-16)
- ·PHP设计聊天室步步通(一)(2013-11-16)
- ·PHP设计聊天室步步通(二) (2013-11-16)
- ·PHP设计聊天室步步通(三) (2013-11-16)
- ·PHP设计聊天室步步通(四) (2013-11-16)
- ·php注册页面代码(mysql+php)(2013-12-11)
- ·php 用户注册页面代码(2013-12-11)
- ·php写的网页计数器代码(2013-12-11)
推荐文章
热门文章
最新评论文章
- 写给考虑创业的年轻程序员(10)
- PHP新手上路(一)(7)
- 惹恼程序员的十件事(5)
- PHP邮件发送例子,已测试成功(5)
- 致初学者:PHP比ASP优秀的七个理由(4)
- PHP会被淘汰吗?(4)
- PHP新手上路(四)(4)
- 如何去学习PHP?(2)
- 简单入门级php分页代码(2)
- php中邮箱email 电话等格式的验证(2)