forked from ririgoei/CS160-Team3
-
Notifications
You must be signed in to change notification settings - Fork 1
/
getUser2.cgi
40 lines (29 loc) · 873 Bytes
/
getUser2.cgi
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/usr/bin/python
import cgi
import psycopg2
#import MySQLdb
import bcrypt
def main():
print "Content-type:text/html\n\n"
try:
# conn = MySQLdb.connect('localhost', "root", "2800", "cs160")
conn = psycopg2.connect("dbname='cs160' user='postgres' host='localhost' password='2800'")
cursor = conn.cursor()
formData = cgi.FieldStorage()
username = formData.getvalue('username')
userpassword = formData.getvalue('password')
sql = 'select password from user_profile where username=%s'
cursor.execute(sql, (username,))
storedPassword = cur.fetchone()
if bcrypt.checkpw(userpassword, storedPassword[0]):
print userpassword + '<br>'
print "Log in Successs"
else:
print 'Log in failed'
conn.commit()
cursor.close()
conn.close()
except:
print "error"
if __name__ == "__main__":
main()