Im using MongoDB with PHP. Im making a check user exist using their email.It can be check, but when I enter the existing user and click the confirm button, it display the 'echo' and also display an error about converted document to int. Below is what the error say and my code.

ERROR
Fatal error: Uncaught Error: Call to a member function count() on null in C:\xampp\htdocs\project\OrgChart-master\OrgChart-master\resetPasswordSuccess.php:36 Stack trace: #0 {main} thrown in C:\xampp\htdocs\project\OrgChart-master\OrgChart-master\resetPasswordSuccess.php on line 36

CODE

<!-- MongoDB Conn With Email Check Function V1 (FUNCTIONING) -->
<!--Line 36 is at if($result==0)-->

<?php
        if(isset($_POST['registration']))
        {
            $registration = ($_POST['registration']);

            if(!empty($registration))
            {                
                $result = $db->collection1->findOne(array("registration"=>$registration));
                //print_r($result);
                if($result->count()==1)
                {
                    echo "Please Enter The Correct Username";
                    header('location: memberForgorPassword.php');
                    return false;
                }
                else if($result->count()==0)
                {
                    echo "Username Exist In Database";
                    header('location: resetPasswordSuccess.php');
                    return true;
                }
            }
        }
?>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.