Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/286.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/mongodb/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在php上显示错误_Php_Mongodb - Fatal编程技术网

在php上显示错误

在php上显示错误,php,mongodb,Php,Mongodb,//我已经更新了我的php代码并改进了我的问题 我有一个登录表单,当我输入错误的密码时,我没有此错误: “您未注册或密码错误!” 我什么都没有,什么都没有出现 这是我的php代码,我的数据是mongodb: <?php if (isset($_POST['submit']) && $_POST['submit'] == "Login"){ $username = strip_tags($_POST['username']); $password = s

//我已经更新了我的php代码并改进了我的问题

我有一个登录表单,当我输入错误的密码时,我没有此错误:

“您未注册或密码错误!”

我什么都没有,什么都没有出现

这是我的php代码,我的数据是mongodb:

<?php



if (isset($_POST['submit']) && $_POST['submit'] == "Login"){
    $username = strip_tags($_POST['username']);
    $password = strip_tags($_POST['password']);
    $error    = array();
    // Username Validation
    if (empty($username)) {
         $error[] = " <h2>  complete username </h2>";
    }
    if (empty($password)) {
         $error[] = " <h2> complete password</h2> ";
    }

        // connexion data
    if (count($error) == 0)
    {
        $host               = 'localhost';
        $database_name      = 'Projet';
        $database_user_name = '';
        $database_password  = '';
        $connection         = new MongoClient();

        if ($connection)
        {
            // select data
            $database = $connection->$database_name;

            // Select collection
            $collection = $database->reg_users;
            $user_data  = array(
                "username" => $username,
                "password" => md5($password)
            );
            $result     = $collection->find($user_data);
            if ($result>0)
            {
                header("Location: Articles.php");
                foreach ($result as $doc)
                 {
                    $_SESSION['email']    = $doc['email'];
                    $_SESSION['username'] = $doc['username'];
                 }

             }else{

                      $error[] = " <h2> your are not register or your password is wrong !  </h2>";
                }

            } else {
                      $error[] = " no mongodb connection";
                }
        }  

         if(count($error) > 0) 
        {
             foreach($error as $e)
             {
                echo $e;
             }
        }
}

isset
将返回一个布尔结果,因此,如果您希望执行该代码块,则需要像这样编写:

if (isset($_POST['submit']) && $_POST['submit'] == "Login")

在数据库端也使用错误报告和。加上这个
if(isset($\u POST['submit'])==“Login”){
根本不会启动。加上#2,谁知道你是否启动了会话。太不清楚了。我一开始就启动了会话。谁能帮我谢谢