注册--审核--登录 例题

Posted 万里冰封

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了注册--审核--登录 例题相关的知识,希望对你有一定的参考价值。

思路:

  注册之后,什么条件可以登录,什么条件不可以登录?

  注册后给一个默认值,进行改变即可登录

  <!--具体操作-->

  注册---->添加页面

  审核---->1,审核成功:审核页面;   2,撤销:审核页面

  登录---->1,成功:跳转页面;         2,失败:返回

 

zhuce.php

 

<body>

<h1 align="center">注册表格</h1>

<form action="zcchuli.php" method="post">
<div  align="center">
<div>用户名<input  type="text" name="uid"/></div>
<div>密码<input  type="text" name="pwd"/></div>
<div>姓名<input  type="text" name="name"/></div>
<div>性别<input  type="text" name="sex"/></div>
<div>生日<input  type="text" name="birthday"/></div>
<div><input  type="submit" value="提交注册"/></div>
</div>
</form>

</body>
</html>

 

 

 

zcchuli.php

 

<?php
$uid=$_POST["uid"];
$pwd=$_POST["pwd"];
$name=$_POST["name"];
$sex=$_POST["sex"];
$birthday=$_POST["birthday"];

if($sex=="男" || $sex=="女")
{
    include("./Tp.class.php");
    $db= new Tp();
    $sql = "insert into Users values(‘{$uid}‘,‘{$pwd}‘,‘{$name}‘,‘{$sex}‘,‘{$birthday}‘,0) ";
    $r=$db->query($sql,1);
    if($r)
    {
        header("location:zhuce.php");
        
    }
}
else
{
    echo "添加失败";    
}


?>

 

login.php

 

 

<body>
<br />
<h3>登录页面</h1>
<form action="lgchuli.php" method="post">
<div>用户名:<input type="text" name="uid" /></div>
<div>密码:<input type="text" name="pwd" /></div>
<div><input type="submit" value="登录" /></div>
</form>



</body>
</html>

 

lgchuli.php

 

 

<?php


$uid = $_POST["uid"];
$pwd = $_POST["pwd"];

include("Tp.class.php");
$db = new Tp();

$sql = "select count(*) from Users where Uid = ‘{$uid}‘ and Pwd= ‘{$pwd}‘ and Isok=1";

$z = $db->StrQuery($sql);

if($z == 1)
{
    
    header("location:xianshi.php");
}
else
{
    header("location:login.php");
}

 

xianshi.php

 

 

<?php

echo "登录成功!!!!!!!<br />进入页面";


?>

 

main.php

<body>
<table border="1" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td>姓名</td>
<td>性别</td>
<td>生日</td>
<td>操作</td>
</tr>
<?php

include("./Tp.class.php");
$db= new Tp();
$sql = "select * from Users ";
$r = $db->query($sql);

foreach($r as $v)
{
    if($v[5]==0)
    {
        echo "<tr>
        <td>{$v[2]}</td>
        <td>{$v[3]}</td>
        <td>{$v[4]}</td>
        <td><a href=‘shenhe.php?uid={$v[0]}‘>审核通过</a></td>
        </tr>";
    }
    else
    {
        
        echo "<tr>
        <td>{$v[2]}</td>
        <td>{$v[3]}</td>
        <td>{$v[4]}</td>
        <td><a href=‘chexiao.php?uid={$v[0]}‘>撤销</a></td>
        </tr>";
        
    }
    
    
}

?>

</table>


</body>
</html>

shenhe.php

<?php

$uid = $_GET["uid"];
include("./Tp.class.php");
$db = new Tp();
$sql = " update Users set Isok = 1 where Uid = ‘{$uid}‘";
$r = $db->query($sql,1);


if($r)
{
    header("location:main.php");    
}
else
{
    echo "审核失败";    
}

?>

chexiao.php

<?php

$uid = $_GET["uid"];
include("./Tp.class.php");
$db = new Tp();
$sql = " update Users set Isok = 0 where Uid = ‘{$uid}‘";
$r = $db->query($sql,1);
if($r)
{
    header("location:main.php");    
}
else
{
    echo "撤销失败";    
}

?>

TP.class.php

<?php

class Tp
{
    public $host="localhost";
    public $uid = "root";
    public $pwd = "123";
    public $dsn="mysql:dbname=mydb;host=localhost";
    public function query($sql,$type=0,$ss="mydb")
    {
        $db = new MySQLi($this->host,$this->uid,$this->pwd,$ss);
        !mysqli_connect_error() or die("连接错误");
        $result = $db->query($sql);
        
        if($type==0)
        {
            return $result->fetch_all();
        }
        else
        {
            return $result;
            
            
        }
    
    }
    
    
    
    public function pdo($sql)
    {
        
        $pdo= new PDO($this->dsn,$this->uid,$this->pwd);
        $stm = $pdo->prepare($sql);
        
        if($stm->execute())
        {
            return $stm->fetchAll();
            echo "运行成功";
        }
        else
        {
            echo "运行失败";    
        }
    }

     //Ajax调用返回字符串
    public function StrQuery($sql,$type=1,$db="mydb")
    {
        //造连接对象
        $conn = new MySQLi($this->host,$this->uid,$this->pwd,$db);
        
        //判断连接是否成功
        !mysqli_connect_error() or die("连接失败!");
        
        //执行SQL语句
        $result = $conn->query($sql);
        
        //判断SQL语句类型
        if($type==1)
        {
            $attr = $result->fetch_all();
            $str = "";
            //如果是查询语句返回字符串
            for($i=0;$i<count($attr);$i++)
            {
                for($j=0;$j<count($attr[$i]);$j++)
                {
                    $str = $str.$attr[$i][$j];
                    $str = $str."^";
                }
                $str = substr($str,0,strlen($str)-1);
                $str = $str."|";
            }
            $str = substr($str,0,strlen($str)-1);
            
            return $str;
        }
        else
        {
            //如果是其他语句,返回true或false
            if($result)
            {
                return "OK";
            }
            else
            {
                return "NO";
            }
        }
    }
    
    
    
}


?>

 

以上是关于注册--审核--登录 例题的主要内容,如果未能解决你的问题,请参考以下文章

注册审核批量删除

注册审核批量删除

注册审核通过

注册审核

php......注册审核

利用PHP连接数据库操作用户注册审核与登录页面