在我们看来 很多地方都会需要我们去注册页面的,比如淘宝购物,下载文件等等
1.注册页面写起来反而是非常简单的,下面会有代码展示:
1 <body> 2 <h1>注册页面</h1> 3 <form action="zhucecl.php " method="post"> 4 <div>学号:<input type="text" name="sno"/><br/> 5 姓名:<input type="text" name="sname"/><br/> 6 性别:<input type="text" name="ssex"/><br/> 7 生日:<input type="text" name="sbirthday"/><br/> 8 班级:<input type="text" name="class"/><br/></div> 9 <input type="submit" value="注册"/> 10 </form> 11 </body>
这是注册页面
2.从注册页面要连接到zhucecl.php 也就是注册处理页面,如果满足条件,也就是注册成功,进入登录页面,如果注册不成功,会提示注册不成功
1 <?php 2 $sno=$_POST["sno"]; 3 $name=$_POST["sname"]; 4 $sex=$_POST["ssex"]; 5 $birthday=$_POST["sbirthday"]; 6 $class=$_POST["class"]; 7 8 include("DADB.class.php"); 9 $db=new DADB(); 10 $sql="insert into student VALUES ('{$sno}','{$name}','{$sex}','{$birthday}','{$class}','0')"; 11 if($db->Query($sql,0)) 12 { 13 header("login.php"); 14 } 15 else{ 16 echo"注册失败"; 17 } 18 ?>
3.注册完事之后要进入登录页面,然后进行登录,下面是登录页面的代码展示:login.php
1 1 <body> 2 2 <h1>登录页面</h1> 3 3 <form action="logincl.php" method="post"> /*连接到处理页面*/ 4 4 学号:<input type="text" name="sno"/><br/> 5 5 姓名:<input type="text" name="sname"/> 6 6 <input type="submit" value="登录"/> 7 7 </form> 8 8 </body>
如图所示:
4.登录页面写好之后要进入登录处理页面了
1 <?php
2 $sno=$_POST["sno"]; 3 $name=$_POST["sname"]; 4 include("DADB.class.php"); 5 $db=new DADB(); 6 $sql="select * from student WHERE sno='{$sno}'"; 7 $arr=$db->Query($sql); 8 if($arr[0][1] ==$name && !empty($name)) //姓名要从数据库调取,而且姓名不能为空 9 { 10 if ($arr[0][5]) // 是否审核 11 { 12 header("location:main.php"); 13 } 14 else{ 15 echo "尚未通过审核"; 16 } 17 18 } 19 else{ 20 echo"登录失败"; 21 }
?>
5. 登录成功后 进入主页审核了,如图是审核的页面代码
1 <body> 2 <h1>审核页面</h1> 3 <table cellpadding="0" cellspacing="0" border="1" width="80%"> 4 <tr> 5 <td>学号</td> 6 <td>姓名</td> 7 <td>性别</td> 8 <td>生日</td> 9 <td>班级</td> 10 <td>操作</td> 11 </tr> 12 13 <?php 14 include("DADB.class.php"); 15 $db=new DADB(); 16 $sql="select * from student "; 17 $arr=$db->Query($sql); 18 foreach($arr as $v) 19 { 20 $str=$v[5]?"<span style='color: green'>已通过</span>":"<a href='tongguo.php?sno={$v[0]}'>审核</a>"; 21 echo"<tr> 22 <td>{$v[0]}</td> 23 <td>{$v[1]}</td> 24 <td>{$v[2]}</td> 25 <td>{$v[3]}</td> 26 <td>{$v[4]}</td> 27 <td>{$str}</td> 28 </tr>"; 29 } 30 ?> 31 </table> 32 </body>
如图即是审核页面
6.到审核页面后要蹦到通过页面进行通过,也就是进入tongguo.php
1 <?php 2 $sno=$_GET["sno"]; 3 4 include("DADB.class.php"); 5 $db=new DADB(); 6 $sql="update student set isok=1 where sno='{$sno}'"; 7 if($db->Query($sql,0)) 8 { 9 header("location:main.php"); 10 } 11 else 12 { 13 echo"审核失败"; 14 } 15 ?>
写到此处为止 点击审核就回变成已审核了。 到此就是一个完成的注册审核了