PHP+DBM的同学录程序(1)
2015-01-24信息快讯网
国内还没有什么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:[email protected]">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>
<?
}
?>