如何在首页上创建登录和注册页面'登录和注册页面是一个div标签覆盖首页'

时间:2019-06-25 17:13:27

标签: php

我有主页,我想在主页的div标签内创建登录和注册表单,这是我可以在display ==块时显示它,并在display == none和不透明==时隐藏它。 3,当新用户打开主页时,他只能看到div下的内容,该内容包含用于访问该内容的登录和注册表单,如果他有帐户,则应该登录;如果没有帐户,则注册,如果没有已经有一个帐户,并且他已经登录,这意味着该会话为isset(),在这种情况下,当用户打开主页时,他可以轻松访问内容

class HomeModel extends UserModel {


    public $result; 
    public $data ;
    public $session;
    public $alarm; 
    public $test;

    public function __construct(){  }


    public function index($id = null){  

        if(isset($id)){

            if(isset($_POST["submitLogin"])){

                $username = $_POST["username"];
                $password = $_POST["password"];  

                if(isset($username) || isset($password)){

                    $alarm = "2";   
                    $test="isset box step";     
                    $data[0] = $this->result;
                    $data[1]=$this->session;
                    $data[2]=$alarm;
                    $data[3]=$test; 

                    $data;

                }else{ 

                    $sql = "SELECT * FROM `the_user` WHERE  username = {$username} ";

                    $result = $this->GetPDO()->prepare($sql);
                    $result->execute();
                    $result = $result->fetchAll(); 

                    if(count($result) >= 0){

                        $session = $username;

                        $alarm = "1"; $test="isset result step ";

                    }else{
                        $alarm = "2";$test="not set result step ";
                    }

                }

                $data[0] = $this->result;
                $data[1] = $this->session; 
                $data[2] = $alarm; 
                $data[3] = $test;

                $data;

            } 
        }else{
            if(isset($_SESSION["username"])){
                $alarm = "1"; 
                $test="yep session step";
                $data[0] = array("test","testder");
                $data[1]=$session;
                $data[2]=$alarm; 
                $data[3]=$test; 

                $data;


            }else{ 

                $alarm = "0";
                $test="none session step";
                $data[2]=$alarm; 
                $data[0]=array(1,1,1); 
                $data[1]="usernameee"; 
                $result = [] ;
                $data[3]=$test; 

                $data; 

            }

        }

        return $data;

    }
}

我写了这段代码,但是我发现它运行不正常

0 个答案:

没有答案