PHP Access Message Board Program

Source: Internet
Author: User

*/

The code is as follows Copy Code

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 ""
< Meta http-equiv= "Content-type" content= "text/html;" charset=gb2312 "/>
<title>< Echo $webname? ></title>
<style type=" Text/css Tutorials ">
<!--
Body {font-size:14px line-height:25px; margin:10px auto; padding:10px; width:680px; border:solid #8aa 1 px;}
A {color: #008; text-decoration:none;}
A:hover {color: #f00; text-decoration:underline;}
HR {color: #8aa; height:1px;}
;
</style>

<body>
?
if ($abc = = "Admin") {
if ($name = = $adminname && $PWS = = $ADMINPWS) {
Setcookie ("admin", $admincookie, Time () +3600); Header ("location:./");
}else{echo "<script>alert (' username or password is wrong!) '); History.back ();</script> ";}
}

if ($ABC = = "Exit") {
Setcookie ("admin", "", Time ()-3600); Header ("location:./");
}

if ($abc = = "Editadmin") {
if (! $webname | |! $name | |! $pws) {
echo "<script>alert (' Message book, username, original password can not be empty!") '); History.back ();</script> ";
}
if ($PWS!= $adminpws) {
echo "<script>alert (' May password be wrong!") '); History.back ();</script> ";
}
if ($NEWPWS!= "") {
$conn->execute ("Update [web] set [webname] = ' $webname ', [name] = ' $name ', [PWS] = ' $NEWPWS '");
$conn->close (); $conn =null;
echo "<script>alert (' modified successfully, please login again!") '); location= ' abc=exit ';</script> ';
}else{
$conn->execute ("Update [web] set [webname] = ' $WEBN ', [name] = ' $name '");
$conn->close (); $conn =null;
echo "<script>alert" (' Modified successfully! '); location= './';</script> ';
}
}
?>

<b> "<a href="./">&lt"? echo $webname?></a> "</b>
<a href= "" > Management </a> if (Isset ($_cookie["admin")) {?> <a href= "" > Modify Data </a> <a href= "" > Safe exit </a><?;}?>
? if ($ABC = = "User" &&!isset ($_cookie["admin")) {?>
<form method= "POST" action= "" >
User name: <input name= "name" type= "text" value= ""/>
Password: <input name= "PWS" type= "password" "value=" "/>
<input name= "Add" type= "Submit" value= "OK"/>
</form>
;?;} ?>
? if ($abc = = "Edituser") {?>
<form method= "POST" action= "" >
Message book: <input name= "WEBN" type= "text" value= " echo $webname?> "size="/>
<br/>
User name: <input name= "name" type= "text" value= " echo $admincookie;?> "/>
Original password: <input name= "PWS" type= "password" value= ""/>
New password: <input name= "NEWPWS" type= "password" value= ""/>
<input name= "Add" type= "Submit" value= "OK"/>
</form>
;?;} ?>

;?
$id =$_get[' id '];
$sj =date (' y-m-d ');
if ($abc = = "Add") {
  $nr =$_post[' nr '];
  $ip =getenv ("remote_addr");
 if (! $nr) {
 echo "<script>alert (' message cannot be empty!") '); History.back ();</script> ";
 }else{
  $conn->execute ("INSERT into [txt] (NR,SJ) VALUES (' $nr ', ' $SJ ')");
 }
  echo "<script>alert" (' Operation successful! '); 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= "" rows= " 8 "style=" LINE-HEIGHT:25PX; ></textarea><br/><br/>
<input name= "Add" type= "submit" value= "post message"/>
</form
</center>


$rs->open ("select * from [TXT] ORDER by [ZD] desc, [SJ] desc", $conn, 1,3);
$rs->pagesi ze=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 () $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 ' > Top </font> ""; else echo "ID.". $i;?>.
? if ($_cookie["admin"]== $admincookie) {?>
Operation: <a href= ' ><? if ($zd ==0) echo "sticky"; else echo "Cancel Top";?></a> |
<a href= ' > Modify/Reply </a> |
<a href= ' > Delete </a>
;?;} ?>
</div>
<div style= "float:right;" >
date:<? echo $SJ;?>
</div>
<div style= "Clear:both" ></div>
</div>
? if ($ABC = = "HF" && $id ==$_get[' id ') {?>
<form method= "POST" action= "id=" echo $id?> ">
Message: <textarea name= "nr" cols= "rows=" 8 "style=" LINE-HEIGHT:25PX; ><? echo $nr; ></textarea><br/>
Reply: <textarea name= "HF" cols= "rows=" 8 "style=" LINE-HEIGHT:25PX; ><? echo $hf; ></textarea><br/>
Operation: <input name= "Add" type= "submit" value= "Reply/modify"/>
</form>
;?;} ?>
<div style= "margin:20px;" >
?
$NR = Str_replace ("", "". " <br/> ', $NR);
$NR = Str_replace ("", ' &nbsp; ', $NR);
echo $nr. " <br/> ";
?>
?
if ($HF!= "") {
echo "<font color= ' #aa0000 ' > Reply:";
$HF = Str_replace ("", "". " <br/> ', $HF);
$HF = Str_replace ("", ' &nbsp;&nbsp; ', $HF);
echo $HF. " </font> ";
}
?>
</div>

? $rs->movenext; $mypagesize--; $i--; Paging Loops?>
<center>
Message number ( echo $rs->recordcount ();?>)
<a href= "" > Home </a>
<a href= "" > Prev </a>
What is the first? Echo $page;? >/<? echo $rs->pagecount;? > Page
<a href= "" > next page </a>
<a href= "" > End </a>&nbsp;
Visit volume (??) echo $ll?>)
</center>
? $rs->close (); $rs =null; $conn->close (); $conn =null;?>

</body>

Database structure
ID name PWS LL webname
1 ABC abc 4 ABC message book PHP+ACC

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.