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.

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


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

            $registration = ($_POST['registration']);

                $result = $db->collection1->findOne(array("registration"=>$registration));
                    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;

I see no line 36. Also line 16 looks suspect. Is it "Forgor" on purpose?

Be a part of the DaniWeb community

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