-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuser.py
61 lines (51 loc) · 1.82 KB
/
user.py
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
52
53
54
55
56
57
58
59
60
61
import pymysql
import customer
conn= pymysql.connect("localhost","root","root","pharmacy")
curs=conn.cursor()
class user:
def __init__(self):
uid=None
def signup(self,cust_details): #DONE
print(cust_details)
curs.execute("""INSERT INTO customer (cname,phone,email,address,password) VALUES(%s,%s,%s,%s,%s)""",(cust_details['Name'], cust_details['Phone'], cust_details['Email'], cust_details['Address'], cust_details['Password']))
conn.commit()
print("Signup Successful!")
def signin(self,uname,password): #DONE
try:
curs.execute("""SELECT password from pharmacy.customer WHERE email=%s""", (uname))
passw=curs.fetchall()
if password==passw[0][0]:
return True
else:
return False
except Exception as e:
print("Wrong Details!")
return False
#Program Menu
print("1.Press 1 for Customer")
print("2.Press 2 for Admin")
choice1=int(input("Enter Choice:"))
if choice1==1:
print("1.Press 1 for Signup")
print("2.Press 2 for signin")
choice2=int(input("Enter choice:"))
if choice2==1:
name = input("Enter your Name:")
password = input("Enter password:")
phone = input("Enter phone number:")
email = input("Enter email address:")
address = input("Enter address:")
obj = customer()
obj.fetchDetails(name,password,phone,email,address)
elif choice2==2:
tf=False
while tf!=True:
uname=input("Enter Username(Email):")
password=input("Enter Password:")
obj=customer()
tf=obj.signin(uname,password)
if tf==True:
print("Login Successful!")
else:
print("Login Unsuccessful!")
#COMPLETED TILL SIGNIN SIGNUP