PHP+DBM的同学录程序(1)
程序员文章站
2022-06-15 16:06:14
这个同学录原来给我们班级用的,因为服务器没有mysql支持,就选择了dbm 国内还没有什么dbm程序,国外也几乎没有 花了一个晚上,在几乎没有任何参考的情况下写了出来 现在...
这个同学录原来给我们班级用的,因为服务器没有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>
<?
}
?>
国内还没有什么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>
<?
}
?>
上一篇: 怎么种西瓜的?要注意什么?
下一篇: 正则表达式模式修正符(/ies)