程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 網頁編程 >> PHP編程 >> 關於PHP編程 >> php access 留言板程序

php access 留言板程序

編輯:關於PHP編程

php access 留言板程序 這裡不是php與mysql的留言板程序,而是一款簡單實用的php access 留言板程序哦,利用了adodb來連接access數據庫哦。

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.bKjia.c0m/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("n","n".'<br/>',$nr);
 $nr = str_replace(" ",'&nbsp;',$nr);
 echo $nr."<br />";
?> 
<?
 if ($hf!=""){
  echo "<font color='#aa0000'>回復:";
  $hf = str_replace("n","n".'<br/>',$hf);
  $hf = str_replace("  ",'&nbsp;&nbsp;',$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>
<a href="">尾頁</a>&nbsp;
訪問量(<? 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

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved