zoukankan      html  css  js  c++  java
  • php注册审核

    注册审核:注册后无法登陆,需要审核通过后才能登录

    需要一个登录页,一个注册页,一个审核页,一个后台

    登录页:

     1 <!DOCTYPE html>
     2 <html>
     3     <head>
     4         <meta charset="UTF-8">
     5         <title></title>
     6     </head>
     7     <body>
     8         <form action="php.php" method="post">
     9             账号:<input name="sname"/><br />
    10             密码:<input name="sno"/><br />
    11             <button>登录</button>
    12             <a href="zhuce.php">注册</a>
    13         </form>
    14     </body>
    15 </html>

     

    注册页:

     1 <?php
     2     if(!empty($_POST)){
     3         $db = new MySQLi('localhost','root','','z_1031');
     4         !mysqli_connect_error() or die('数据库连接失败');
     5         $db->query('set names utf8');
     6         
     7         
     8         
     9         //接收值
    10         $sno=$_POST['sno'];
    11         $sname=$_POST['sname'];
    12         $ssex=$_POST['ssex'];
    13         $sbirthday=$_POST['sbirthday'];
    14         $class=$_POST['class'];
    15         
    16         
    17         $sql="insert into student values('$sno','$sname','$ssex','$sbirthday','$class',0)";
    18         $res = $db->query($sql);
    19         if($res){
    20             echo "<span>注册成功</span>";
    21         }else{
    22             echo "注册失败";
    23         }
    24         
    25     }
    26 ?>
    27 <!DOCTYPE html>
    28 <html>
    29     <head>
    30         <meta charset="utf-8" />
    31         <title></title>
    32     </head>
    33     <body>
    34         <form action="#" method="post">
    35             学号:<input name="sno"/><br />
    36             姓名:<input name="sname"/><br />
    37             性别:<input name="ssex"/><br />
    38             生日:<input name="sbirthday"/><br />
    39             班级:<input name="class"/><br />
    40             <button>注册</button>
    41             <a href="list.php">查看用户列表</a>
    42         </form>
    43     </body>
    44 </html>

    html代码也写在php中

    审核页:

     1 <?php
     2 //连接数据库
     3 $db = new MySQLi('localhost','root','','z_1031');
     4 !mysqli_connect_error() or die('数据库连接失败');
     5 $db->query('set names utf8'); //设置字符集
     6 
     7 if(!empty($_GET['id'])){
     8     echo $_GET['id'];
     9     $sno = $_GET['id'];
    10     /*修改*/
    11     $sql = "update student set status = 1 where sno = '$sno'";
    12     $res = $db->query($sql);
    13 }
    14 
    15 
    16 
    17 //查询数据
    18 $sql="select * from student where status>=0";
    19 $res=$db->query($sql);
    20 $arr = $res->fetch_all();
    21 //var_dump($arr);
    22 ?>
    23 
    24 
    25 
    26 
    27 
    28 <!DOCTYPE html>
    29 <html>
    30     <head>
    31         <meta charset="UTF-8">
    32         <title></title>
    33     </head>
    34     <style>
    35         .spanERR{
    36             background: red;
    37             cursor: pointer;
    38         }    
    39         .spanSU{
    40             background: #32F730;
    41             cursor: pointer;
    42         }
    43     </style>
    44     <body>
    45         <table width="100%" border="1" cellpadding="0" cellspacing="0">
    46             <tr>
    47                 <th>学号</th>
    48                 <th>姓名</th>
    49                 <th>性别</th>
    50                 <th>生日</th>
    51                 <th>班级</th>
    52                 <th>操作</th>
    53             </tr>
    54             <!--这边就是循环-->
    55             <?php foreach($arr as $v){ ?>
    56                 <tr>
    57                     <td><?php echo $v[0]; ?></td>
    58                     <td><?php echo $v[1]; ?></td>
    59                     <td><?php echo $v[2]; ?></td>
    60                     <td><?php echo $v[3]; ?></td>
    61                     <td><?php echo $v[4]; ?></td>
    62                     <td><?php echo $v[5]==0 ? "<a href='list.php?id=$v[0]'><span class='spanERR'>待审核</span></a>" : '<span class="spanSU">已通过</span>'; echo $v[0]; ?></td>
    63                 </tr>
    64             <?php } ?>
    65         </table>
    66     </body>
    67 </html>

    点击待审核显示已通过

    后台:

     1 <?php
     2 //连接数据库
     3 $db = new MySQLi('localhost','root','','z_1031');
     4 !mysqli_connect_error() or die('数据库连接失败');
     5 $db->query('set names utf8');
     6 
     7 $sno = $_POST['sno'];
     8 $sname = $_POST['sname'];
     9 //审核 审核状态为通过 或者是管理员
    10 $sql="select sno from student where sname='$sname' and status !=0";
    11 $res=$db->query($sql);
    12 $arr=$res->fetch_row();
    13 
    14 
    15 //判断给结果
    16 if($sno!=""&&$arr==""){
    17     echo "账号密码错误或者未通过审核";
    18 }else{
    19     echo "登陆成功";
    20 }
    
  • 相关阅读:
    (Delphi) Using the Disk Cache 使用磁盘缓存
    当电视沦为“情怀”,5G能不能拯救它?(zz)
    何为优秀的机器学习特征 zz
    BP神经网络算法推导及代码实现笔记zz
    偏差(Bias)和方差(Variance)——机器学习中的模型选择zz
    关于管理,你可能一直有 3 个误解zz
    读《赋能》有感zz
    Concept Drift(概念漂移)
    第四范式涂威威:AutoML技术现状与未来展望
    韩家炜在数据挖掘上开辟的「小路」是什么
  • 原文地址:https://www.cnblogs.com/liangdong/p/10224962.html
Copyright © 2011-2022 走看看