【phpstudy】php access 留言板程序

更新时间:2016-09-05    来源:Access    手机版     字体:

【www.bbyears.com--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();
?>




<? echo $webname ?>


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>";
 }
}
?>


管理 修改资料 安全退出

 


  用户名:
  密码:
  
 



 

  留言本:
  

  用户名:
  原密码:
  新密码:
  
 


$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:./");
}
?>











//分页
$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;
?>



置顶 】"; else echo "id.".$i; ?>
 
操作: |
修改/回复 |
删除



date:






 

 留言:

 回复:

 操作:
 

 

 $nr = str_replace(" "," "."
",$nr);
 $nr = str_replace(" "," ",$nr);
 echo $nr."
";
?> 
 if ($hf!=""){
  echo "回复:";
  $hf = str_replace(" "," "."
",$hf);
  $hf = str_replace("  ","  ",$hf);
  echo $hf."
";
 }
?>


movenext; $mypagesize--; $i--; } } //分页循环 ?>


留言数(recordcount(); ?>)
首页
上页
/pagecount;?>页
下页
尾页 
访问量(

close(); $rs=null; $conn->close(); $conn=null; ?>


数据库结构
id name pws ll webname
1 abc abc 4 abc 留言本 php+acc

本文来源:http://www.bbyears.com/shujuku/26609.html

猜你感兴趣