diff --git a/src/app/model.py b/src/app/model.py index 4a49384..8d475cb 100644 --- a/src/app/model.py +++ b/src/app/model.py @@ -18,15 +18,17 @@ def get_users(): def match_user(username, password): cursor = db.cursor() - query = ("SELECT userid, username from users where username = (%s) and password = (%s)") - cursor.execute(query, (username, password)) + query = ("SELECT userid, username from users where username = \"" + username + + "\" and password = " + password) + cursor.execute(query) user = cursor.fetchall() return user def set_user(username, password): cursor = db.cursor() - query = ("INSERT INTO users VALUES (NULL, (%s), (%s))") - cursor.execute(query, (username, password)) + query = ("INSERT INTO users VALUES (NULL, " + username + + ", " + password + ")") + cursor.execute(query) cursor.close() def get_guestbook_entries(): diff --git a/src/app/views.py b/src/app/views.py index ad06d41..f67c385 100644 --- a/src/app/views.py +++ b/src/app/views.py @@ -44,10 +44,12 @@ class index(): data = web.input() user = model.match_user(data.username, data.password) # If there is a matching user/password in the database the user is logged in - if len(user) == 1: + if len(user): friends = model.get_users() session.username = data.username - return render.index(login_form, friends) + else: + friends = [[],[]] + return render.index(login_form, friends) class register: