add.php
======================================================================
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<table border="0" cellspacing="0" cellpadding="4">
<tr>
<td><a href="index.php">首页</a></td>
<td><a href="add.php">添加管理员</a></td>
<td> </td>
<td> </td>
</tr>
</table>
<form name="form1" method="post" action="add.php">
<table width="400" border="1" align="center" cellpadding="4" cellspacing="0" bordercolor="#CCCCCC" bordercolordark="#FFFFFF">
<tr bgcolor="#CCCCCC">
<td colspan="2"><div align="center">添加管理员</div></td>
</tr>
<tr>
<td width="122" nowrap><div align="right">管理员帐号:</div></td>
<td width="256"><input name="adminname" type="text" id="adminname" maxlength="20"></td>
</tr>
<tr>
<td nowrap><div align="right">管理员密码:</div></td>
<td><input name="adminpwd" type="password" id="adminpwd" maxlength="50"></td>
</tr>
<tr>
<td nowrap><div align="right">重复密码:</div></td>
<td><input name="repwd" type="password" id="repwd" maxlength="50"></td>
</tr>
<tr>
<td nowrap><div align="right">管理员名称:</div></td>
<td><input name="uname" type="text" id="uname" maxlength="10"></td>
</tr>
<tr>
<td nowrap><div align="right">管理员级别:</div></td>
<td><select name="user_level">
<option value="超级管理员">超级管理员</option>
<option value="普通管理员" selected>普通管理员</option>
</select></td>
</tr>
<tr>
<td colspan="2"><div align="center">
<input type="submit" name="Submit" value="提交">
</div></td>
</tr>
</table>
</form>
<?php
//包含数据库链接文件
include "conn.php";
//接收表单提交的数据
if (isset($_POST["Submit"]))
{
if (isset($_POST["adminname"]))$adminname=$_POST["adminname"];
if (isset($_POST["adminpwd"]))$adminpwd=$_POST["adminpwd"];
if (isset($_POST["repwd"]))$repwd=$_POST["repwd"];
if (isset($_POST["uname"]))$uname=$_POST["uname"];
if (isset($_POST["user_level"]))$user_level=$_POST["user_level"];
//判断表单值是否合法
if ($adminname=="")
{
echo("<script language=javascript>alert(\"请输入管理员帐号!\");history.go(-1);</script>");
exit();
}
if ($adminpwd=="")
{
echo("<script language=javascript>alert(\"请输入管理员密码!\");history.go(-1);</script>");
exit();
}
if ($adminname<>$repwd)
{
echo("<script language=javascript>alert(\"两次输入密码不一致,请重新输入!\");history.go(-1);</script>");
exit();
}
if ($uname=="")
{
echo("<script language=javascript>alert(\"请输入管理员名称!\");history.go(-1);</script>");
exit();
}
//添加数据到数据库
if ($adminname<>"" and $adminpwd<>"")
{
$rs=$conn->execute("insert into ad_admin(adminname,adminpwd,uname,user_level) values('$adminname','$adminpwd','$uname','$user_level')");
echo ("管理员 $adminname 添加成功!");
}
}
?>
============================================================================
index.php
=============================================================================
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<table border="0" cellspacing="0" cellpadding="4">
<tr>
<td><a href="index.php">首页</a></td>
<td><a href="add.php">添加管理员</a></td>
<td> </td>
<td> </td>
</tr>
</table>
<table width="100%" border="1" cellpadding="2" cellspacing="0" bordercolor="#CCCCCC" bordercolordark="#FFFFFF">
<tr bgcolor="#CCCCCC">
<td nowrap><div align="center">编号</div></td>
<td nowrap><div align="center">帐号</div></td>
<td nowrap><div align="center">名称</div></td>
<td nowrap><div align="center">级别</div></td>
<td nowrap><div align="center">添加时间</div></td>
</tr>
<?php
//包含数据库链接文件
include "conn.php";
//查询数据库,显示数据
$rs=$conn->execute("select * from ad_admin");
$i=0;
if (!$rs->eof and !$rs->bof)
{
while (!$rs->eof and !$rs->bof){
?>
<tr>
<td> <?php echo $rs["id"] ?> </td>
<td> <?php echo $rs["adminname"] ?> </td>
<td> <?php echo $rs["uname"] ?> </td>
<td> <?php echo $rs["user_level"] ?> </td>
<td> <?php echo $rs["sj"] ?> </td>
</tr>
<?php
$i+=1;
$rs->movenext();
}
}
$rs->close();
?>
</table>
================================================================
conn.php
================================================================
<?php
$conn=new com("adodb.connection");
$conn->open("driver=microsoft access driver (*.mdb);dbq=ad.mdb");
?>
======================================================================
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<table border="0" cellspacing="0" cellpadding="4">
<tr>
<td><a href="index.php">首页</a></td>
<td><a href="add.php">添加管理员</a></td>
<td> </td>
<td> </td>
</tr>
</table>
<form name="form1" method="post" action="add.php">
<table width="400" border="1" align="center" cellpadding="4" cellspacing="0" bordercolor="#CCCCCC" bordercolordark="#FFFFFF">
<tr bgcolor="#CCCCCC">
<td colspan="2"><div align="center">添加管理员</div></td>
</tr>
<tr>
<td width="122" nowrap><div align="right">管理员帐号:</div></td>
<td width="256"><input name="adminname" type="text" id="adminname" maxlength="20"></td>
</tr>
<tr>
<td nowrap><div align="right">管理员密码:</div></td>
<td><input name="adminpwd" type="password" id="adminpwd" maxlength="50"></td>
</tr>
<tr>
<td nowrap><div align="right">重复密码:</div></td>
<td><input name="repwd" type="password" id="repwd" maxlength="50"></td>
</tr>
<tr>
<td nowrap><div align="right">管理员名称:</div></td>
<td><input name="uname" type="text" id="uname" maxlength="10"></td>
</tr>
<tr>
<td nowrap><div align="right">管理员级别:</div></td>
<td><select name="user_level">
<option value="超级管理员">超级管理员</option>
<option value="普通管理员" selected>普通管理员</option>
</select></td>
</tr>
<tr>
<td colspan="2"><div align="center">
<input type="submit" name="Submit" value="提交">
</div></td>
</tr>
</table>
</form>
<?php
//包含数据库链接文件
include "conn.php";
//接收表单提交的数据
if (isset($_POST["Submit"]))
{
if (isset($_POST["adminname"]))$adminname=$_POST["adminname"];
if (isset($_POST["adminpwd"]))$adminpwd=$_POST["adminpwd"];
if (isset($_POST["repwd"]))$repwd=$_POST["repwd"];
if (isset($_POST["uname"]))$uname=$_POST["uname"];
if (isset($_POST["user_level"]))$user_level=$_POST["user_level"];
//判断表单值是否合法
if ($adminname=="")
{
echo("<script language=javascript>alert(\"请输入管理员帐号!\");history.go(-1);</script>");
exit();
}
if ($adminpwd=="")
{
echo("<script language=javascript>alert(\"请输入管理员密码!\");history.go(-1);</script>");
exit();
}
if ($adminname<>$repwd)
{
echo("<script language=javascript>alert(\"两次输入密码不一致,请重新输入!\");history.go(-1);</script>");
exit();
}
if ($uname=="")
{
echo("<script language=javascript>alert(\"请输入管理员名称!\");history.go(-1);</script>");
exit();
}
//添加数据到数据库
if ($adminname<>"" and $adminpwd<>"")
{
$rs=$conn->execute("insert into ad_admin(adminname,adminpwd,uname,user_level) values('$adminname','$adminpwd','$uname','$user_level')");
echo ("管理员 $adminname 添加成功!");
}
}
?>
============================================================================
index.php
=============================================================================
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<table border="0" cellspacing="0" cellpadding="4">
<tr>
<td><a href="index.php">首页</a></td>
<td><a href="add.php">添加管理员</a></td>
<td> </td>
<td> </td>
</tr>
</table>
<table width="100%" border="1" cellpadding="2" cellspacing="0" bordercolor="#CCCCCC" bordercolordark="#FFFFFF">
<tr bgcolor="#CCCCCC">
<td nowrap><div align="center">编号</div></td>
<td nowrap><div align="center">帐号</div></td>
<td nowrap><div align="center">名称</div></td>
<td nowrap><div align="center">级别</div></td>
<td nowrap><div align="center">添加时间</div></td>
</tr>
<?php
//包含数据库链接文件
include "conn.php";
//查询数据库,显示数据
$rs=$conn->execute("select * from ad_admin");
$i=0;
if (!$rs->eof and !$rs->bof)
{
while (!$rs->eof and !$rs->bof){
?>
<tr>
<td> <?php echo $rs["id"] ?> </td>
<td> <?php echo $rs["adminname"] ?> </td>
<td> <?php echo $rs["uname"] ?> </td>
<td> <?php echo $rs["user_level"] ?> </td>
<td> <?php echo $rs["sj"] ?> </td>
</tr>
<?php
$i+=1;
$rs->movenext();
}
}
$rs->close();
?>
</table>
================================================================
conn.php
================================================================
<?php
$conn=new com("adodb.connection");
$conn->open("driver=microsoft access driver (*.mdb);dbq=ad.mdb");
?>