PHP+DBM的同學錄程式(1)_php基礎
來源:互聯網
上載者:User
這個同學錄原來給我們班級用的,因為伺服器沒有mysql支援,就選擇了dbm
國內還沒有什麼dbm程式,國外也幾乎沒有
花了一個晚上,在幾乎沒有任何參考的情況下寫了出來
現在公布出來
是一個非常好的dbm使用範例
1、index.php3
<?
if($login){
?>
<HTML>
<HEAD>
<TITLE>深圳中學2000屆高中(12)班同學錄</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 #4a3163;
border-right: 1px solid #4a3163; border-top: 1px solid #4a3163;
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>深圳中學2000屆高中(12)班同學錄</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">姓名</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">郵件地址</font></td>
<td width=19% bgcolor="#336699"><font color="#FFFFFF">詳細資料</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\">點擊查看</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>修改資料</font></a>||<a href="changepwd.php3"><font color=#FFFFFF>修改密碼</font></a>||<a href="logout.php3"><font color=#FFFFFF>點擊退出</font></a></font></td>
</tr>
</table>
<p align="center"> Ex同學錄v1.0版本程式製作:<a href="mailto:y10k@963.net">y10k</a><br>
歡迎訪問:<a href="http://www.best4cn.com" target="_blank">http://www.best4cn.com</a> </p>
</body></html>
<?
}else header("location:login.php3");
?>
2、更改密碼的changepwd.php3
<?
require("common.php3");
if($submit){
$id=$login;
if($id==false)error("請登陸後再修改密碼");
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("您兩次輸入的密碼不一樣啊!");
}else error("對不起,您輸入的原來的密碼錯誤,不能修改密碼!");
}
}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>使用者修改密碼</FONT></TD>
</TR>
<TR align=middle>
<TD align=middle bgColor=#f7f7f7 width="122">
<P align=center>老的密碼</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>新的密碼</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>重複密碼</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=確認修改>
<INPUT class=stbtm type=reset value=重新修改 name="reset">
</P>
</DIV>
</TD>
</TR>
</TBODY>
</TABLE>
</CENTER></FORM></BODY></HTML>
<?
}
?>