Hi Guys, I'm new to python so apologies for any stupid bits of code.
So basically im trying to get a login script to work, which checks to see if that user is in the users table in the database. So if your name and password input matches database entry then proceed.
Not sure how to check the values against the database.
But here is what what i have got so far:
Currently it is displaying "Successfully logged in" no matter what i enter.
I know the if statement is wrong but not sure what to change it to.
Any suggestions folks
Thanks
So basically im trying to get a login script to work, which checks to see if that user is in the users table in the database. So if your name and password input matches database entry then proceed.
Not sure how to check the values against the database.
But here is what what i have got so far:
Code:
@route('/login')
def login_form():
return template ('login.tpl')
@route('/checkLogin', method='post')
def login_submit():
name = request.forms.get('name')
password = request.forms.get('password')
connect = sqlite3.connect('project1.db')
cursor = connect.cursor()
cursor.execute("SELECT name,password FROM users")
connect.commit()
cursor.close()
connect.close()
if((name==request.forms.get('name')) & (password==request.forms.get('password'))):
return template('loggedIn.tpl', message='Successfully logged in!')
else:
return template('loggedIn.tpl', message='Unlucky! Try again.')
Currently it is displaying "Successfully logged in" no matter what i enter.
I know the if statement is wrong but not sure what to change it to.
Any suggestions folks
Thanks