PHP + DBM logging program (1)

Source: Internet
Author: User

This example was originally used for our class. Because the server does not support mysql, dbm is selected.
There is no dbm program in China, and there is almost no dbm program abroad.
It took me one night to write it out without any reference.
Published now
Is a very good dbm use example

1. index. php3
<?
If ($ login ){
?>
<HTML>
<HEAD>
<TITLE> transcript of Class 12 of the 2000 Shenzhen High School </TITLE>

<Style type = "text/css">
A {text-decoration: none; color: #336699; font-family: ""; font-size: 9pt}
A: hover {text-decoration: underline; color: # FF0000; font-family: ""; font-size: 9pt}
Body {font-family: "", "serif"; font-size: 9pt}
Td {font-family: "", "serif"; font-size: 9pt}
Input {font-size: 9pt}
P {font-size: 9pt}
Br {font-size: 9pt}
Tr {font-size: 9pt}
Table {font-size: 9pt}
INPUT {FONT-FAMILY: arial,; FONT-SIZE: 9pt; PADDING-TOP: 3px}
INPUT. text {
BACKGROUND-COLOR: # f0f0f0; BORDER-BOTTOM: #101010 1px solid; BORDER-LEFT: #101010 1px solid; BORDER-RIGHT: #101010 1px solid; BORDER-TOP: #101010 1px solid; COLOR: #000000
}
INPUT. file {
BACKGROUND-COLOR: # f0f0f0; BORDER-BOTTOM: #101010 1px solid; BORDER-LEFT: #101010 1px solid; BORDER-RIGHT: #101010 1px solid; BORDER-TOP: #101010 1px solid; COLOR: #000000
}
SELECT {
BACKGROUND-COLOR: # f0f0f0; BORDER-BOTTOM: #101010 1px solid; BORDER-LEFT: #101010 1px solid; BORDER-RIGHT: #101010 1px solid; BORDER-TOP: #101010 1px solid; COLOR: #000000
}
TEXTAREA {
BACKGROUND-COLOR: # f0f0f0; BORDER-BOTTOM: #101010 1px solid; BORDER-LEFT: #101010 1px solid; BORDER-RIGHT: #101010 1px solid; BORDER-TOP: #101010 1px solid; COLOR: #000000
}
. Stedit {font-size: 9pt; border-left: 1px solid #4a00003;
Border-right: 1px solid #4a00003; border-top: 1px solid #4a00003;
Border-bottom: 1px solid #000066}
. Stbtm {background-color: # cococo; color: #000000; font-size: 9pt; height: 20px;
Border-left: 1px solid # ffffff; border-right: 1px solid # 665b8e;
Border-top: 1px solid # ffffff; border-bottom: 1px solid # 665b8e}
. Ddd {COLOR: # ffffff; FILTER: glow (color = black, strength = 1); FONT-SIZE: 9pt; LINE-HEIGHT: 13pt; POSITION: relative; WIDTH: 100%}
</Style>

</HEAD>
<Body bgcolor = "# FFFFFF">
<P class = pt10 align = center> <B> transcript of the 2000 High School (12) class of Shenzhen middle school </B> <br>
<Table border = "0" width = "80%" cellpadding = "2" cellspacing = "1" bgcolor = "#000000" align = "center">
<Tr align = center>
<Td width = 19% bgcolor = "#336699"> <font color = "# FFFFFF"> name </FONT> </td>
<Td width = 17% bgcolor = "#336699"> <font color = "# FFFFFF"> NickName </font> </td>
<Td width = 18% bgcolor = "#336699"> <font color = "# FFFFFF"> OICQ </FONT> </td>
<Td width = 27% bgcolor = "#336699"> <font color = "# FFFFFF"> email address </font> </td>
<Td width = 19% bgcolor = "#336699"> <font color = "# FFFFFF"> details </font> </td>
</Tr>
<?
$ Dbm = dbmopen ("class", "r ");
$ Key = dbmfirstkey ($ dbm );
While ($ key ){
$ Data = dbmfetch ($ dbm, $ key );
$ Info = explode ("|! :! | ", $ Data );
Echo "<tr BGCOLOR = \" # FFF5E1 \ "align = \" center \ "> <td width = 19%> <a href = show. php3? Id = $ key> $ info [0] </a> </td> <td width = 17%> $ info [1] </td> <td width = 18%> $ info [4] </td> <td width = 27%> $ info [2] </td> <td width = 19%> <a href = \ "show. php3? Id = $ key \ "> click to view </a> </td> </tr> ";
$ Key = dbmnextkey ($ dbm, $ key );
}
?>
<Tr BGCOLOR = "#336699" align = "center">
<Td colspan = "5"> <font color = # FFFFFF> <a href = "modify. php3 "> <font color = # FFFFFF> modify data </font> </a> | <a href =" changepwd. php3 "> <font color = # FFFFFF> Change Password </font> </a> | <a href =" logout. php3 "> <font color = # FFFFFF> click to exit </font> </a> </font> </td>
</Tr>
</Table>
<P align = "center"> Ex release record v1.0 Program Production: <a href = "mailto: y10k@963.net"> y10k </a> <br>
Welcome to <a href = "http://www.best4cn.com" target = "_ blank"> http://www.best4cn.com </a> </p>
</Body> <?
} Else header ("location: login. php3 ");
?>

2. Change the password's changepwd. php3
<?
Require ("common. php3 ");
If ($ submit ){
$ Id = $ login;
If ($ id = false) error ("Please log on and change your password ");
Else {
$ Data = dbmopen ("password", "w ");
$ Pass = dbmfetch ($ data, $ login );
If ($ password = $ pass ){
If ($ password2 ==$ password1 ){
Dbmreplace ($ data, $ id, $ password2 );
Header ("location: index. php3 ");
} Else error ("the password you entered twice is different! ");
} Else error ("sorry, the original password you entered is incorrect. You cannot change the password! ");
}
} Else {
?>
<! Doctype html public "-// W3C // dtd html 4.0 Transitional // EN">
<HTML> <HEAD>
<META content = "text/html; charset = gb2312" http-equiv = Content-Type> <LINK
Href = "style.css" rel = stylesheet>
<META content = "MSHTML 5.00.2614.3500" name = GENERATOR> </HEAD>
<BODY bgColor = # ffffff>
<FORM action = changepwd. php3 method = post>
<CENTER>
<TABLE bgColor = #000000 border = 0 cellSpacing = 1>
<TBODY>
<TR align = middle>
<TD align = middle bgColor = #336699 colSpan = 4> <FONT
Color = # ffffff> Change Password </FONT> </TD>
</TR>
<TR align = middle>
<TD align = middle bgColor = # f7f7f7 width = "122">
<P align = center> old password </P>
</TD>
<TD align = middle bgColor = # f7f7f7 colspan = "3" width = "205">
<INPUT
Class = stedit name = password>
</TD>
</TR>
<Tr align = middle>
<Td align = middle bgcolor = # f7f7f7 width = "122">
<P align = center> New Password </p>
</Td>
<Td align = middle bgcolor = # f7f7f7 colspan = "3" width = "205">
<Input
Class = stedit name = password1>
</Td>
</Tr>
<Tr align = middle>
<Td align = middle bgcolor = # f7f7f7 width = "122">
<P align = center> duplicate password </p>
</Td>
<Td align = middle bgcolor = # f7f7f7 colspan = "3" width = "205">
<Input
Class = stedit name = password2>
</Td>
</Tr>
<TR align = middle>
<TD align = middle bgColor = # f7f7f7 colSpan = 4>
<DIV align = center>
<P>
<INPUT class = stbtm name = submit type = submit value = confirm modification>

<INPUT class = stbtm type = reset value = Re-Modify name = "reset">
</P>
</DIV>
</TD>
</TR>
</TBODY>
</TABLE>
</CENTER> </FORM> </BODY> </HTML>
<?
}
?>

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.