The program search on username and password in the mongodb. If i try with the correct credentials, the code comes in the if statement. If i try to login with bad credentials the code didn't reach the else statement.
I tried it with the elif statement: If username and password not in i.values()
<pre><code class="python"># python code
from pymongo import MongoClient
import pymongo
import pprint
client = MongoClient('192.168.37.128:27017')
db = client.medewerkerdb
collection = db.medewerkerdb
username = input("Username: ")
password = input("Password: ")
cursor = db.medewerkerdb.find({'username': username,'password':password})
for i in cursor:
if username and password in i.values():
print("<h2>Welcome %s </h2>" % (username))`enter code here`
else:
print("Bad Password")
print("2")
print(i)
</code></pre>
The program closes with a Process finished with exit code 0