1.题库管理员注册register.php:
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>注册用户</title>
</head>
<body bgcolor="white" text="black" link="blue" vlink="purple" alink="red">
<h1 align="center">用户注册</h1>
<form name="form1" action="reg_chk.php" method=post>
<p align="center">登录账户:<input type="text" name="login"></input></p>
<p align="center">用户姓名:<input type="text" name="name"></input></p>
<p align="center">身份证号:<input type="text" name="id"></input></p>
<p align="center">用户密码:<input type="password" name="password"></input></p>
<p align="center">密码确认:<input type="password" name="repassword"></input></p>
<p align="center">性别:<input type="radio" name="sex" value="b">男<input type="radio" name="sex" value="g">女
<p align="center">用户住址:<input type="text" name="address"></input>
<p align="center"><input type="submit" name="send" value="注册"><input type="reset" name="重设" value="取消">
</form>
</body>
</html>
2.验证注册与否界面(reg_chk.php):
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
<?php
//检查数据
/* Connectint,selecting database */
$link=mysql_connect('localhost','root','lizhaoyi')
or die("Could not connect:".mysql_error());
//echo "Connected successfully";
mysql_select_db("db_testsystem") or die("Could not select database");
if($_POST['login']=='' or $_POST['name']=='' or $_POST['id']==''or $_POST['password']==''or $_POST['repassword']==''
or $_POST['sex']==''or $_POST['address']==''){
echo "字段不可空白";
exit;
}
if($_POST['password']!=$_POST['repassword']){
echo "两次输入的密码不相同,请重新输入";
exit;
}
$sqlstr="insert into tb_admin values('".$_POST['login']."','".$_POST['name']."','".$_POST['id']."','".$_POST['password']."',
'".$_POST['sex']."','".$_POST['address']."',now(),'1')";
//组合sql
$result=mysql_query($sqlstr,$link);
//执行sql
//跳至窗口页
if($result){
echo "注册成功!";
}else{
echo "注册用户失败或登录用户已存在或身份证号已存在,请重新注册";
}
?>
3.显示注册用户的全部信息界面(show_admin.php):
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
<?php
//检查数据
/* Connectint,selecting database */
$link=mysql_connect('localhost','root','lizhaoyi')
or die("Could not connect:".mysql_error());
//echo "Connected successfully";
mysql_select_db("db_testsystem") or die("Could not select database");
$sqlstr="select * from tb_admin where adm_login=
(select par_descript from tb_parameter where par_id=
(select max(par_id) from tb_parameter));";
mysql_query("SET NAMES GB2312");
$result=mysql_query($sqlstr,$link);
/*if(!$result){die("Valid result!");}
echo "<table>";
echo "<tr><td>登录账户</td><td>用户姓名</td><td>身份证号"*/
$row=mysql_fetch_array($result,MYSQL_BOTH);
if(mysql_num_rows($result)==1){
echo ("<h1 align=center>用户注册成功,您的注册信息如下</h1>");
echo ("<p align=center>登录账户:<font color=blue>".$row[1]."</font></p>");
echo ("<p align=center>用户姓名:<font color=blue>".$row[2]."</font></p>");
echo ("<p align=center>身份证号:<font color=blue>".$row[3]."</font></p>");
echo ("<p align=center>用户密码:<font color=blue>".$row[4]."</font></p>");
echo ("<p align=center>用户性别:<font color=blue>".$row[5]."</font></p>");
echo ("<p align=center>注册时间:<font color=blue>".$row[6]."</font></p>");
echo ("<p align=center>用户住址:<font color=blue>".$row[7]."</font></p>");
}else{
echo "用户注册失败";
}
?>
4.题库管理员登录界面login.php:
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>用户登录</title>
</head>
<body bgcolor="white" text="black" link="blue" vlink="purple" alink="red">
<h1 align="center">用户登录</h1>
<form name="form1" action=login_chk.php method=post>
<p align="center">登录用户:<input type="text" name="login"></input></p>
<p align="center">用户密码:<input type="password" name="password"></input></p>
<p align="center"><input type="submit" name="登录" value="登录" ><input type="reset" name="取消" value="取消"></input>
</form>
<h3 align="center"><a href=register.php>注册</a></h3>
<h3 align="center"><a href=notice.php>用户使用注意事项</a></h3>
</body>
</html>
5.验证登录成功与否界面(login_chk.php):
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
<?php
//检查数据
/* Connectint,selecting database */
$link=mysql_connect('localhost','root','lizhaoyi')
or die("Could not connect:".mysql_error());
//echo "Connected successfully";
mysql_select_db("db_testsystem") or die("Could not select database");
if($_POST['login']=='' or $_POST['password']==''){
echo "字段不可空白!";
exit;
}
$sqlstr="select * from tb_admin where adm_login='".$_POST['login']."'and adm_password='".$_POST['password']."'and adm_select='1'";
$result=mysql_query($sqlstr,$link);
$row=mysql_fetch_array($result,MYSQL_BOTH);
if(mysql_num_rows($result)==1){
echo "注册成功";
$sqlstr="insert into tb_parameter values(null,'".$_POST['login']."')";
$result=mysql_query($sqlstr,$link);
}else{
echo "用户或密码错误!登录失败,请重新登录!";
}