-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathUserMod.py
More file actions
51 lines (49 loc) · 1.69 KB
/
UserMod.py
File metadata and controls
51 lines (49 loc) · 1.69 KB
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
41
42
43
44
45
46
47
48
49
50
51
import sqlite3 as lite
def Login(): ## return true if login success, false if login fail
con = lite.connect('CourseSystem.db')
print("Enter your Login information:")
account = input("account:") ## Input account
cur=con.cursor()
command = "select * from student WHERE account = '" + account + "'"
cur.execute(command)
row=cur.fetchone()
###
if row==None: ## Not register yet
print("Account Not Found")
return False
###
Password = input("password:") ## Input Password
if row[6] == Password : ## successfully login
print("you are successfully login now")
return True
else : ## Password Error
print("Password Incorrect")
return False
def Register(): ## Sign Up account
con = lite.connect('CourseSystem.db')
cur=con.cursor()
###
print("Enter account information to Sign up")
student_id = input("studentID:")
name = input("name:")
grade = input("grade:")
major = input("major:")
## check if account is already used
while True:
account = input("account:")
command = "select * from student WHERE account = '" + account + "'"
cur.execute(command)
row=cur.fetchone()
if row != None:
print("account is already used, enter another one")
else:
break
##
password = input("password:")
with con:
cur=con.cursor()
command = f"Insert into student Values(null, '{student_id}', '{name}', {grade}, '{major}', '{account}', '{password}')"
cur.execute(command)
print("Successfully sign up")
# Login()
# Register()