/
login6.py
196 lines (189 loc) · 8.24 KB
/
login6.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
from termcolor1 import *
import re
import sys
import mysql.connector
from random import *
from getpass import getpass
cid=0
class loginpage:
def customer(self):
from main import User
obj3=User()
cnx=mysql.connector.connect(user='user02',password='Tata@1234',host='127.0.0.1',database='group6')
cursor=cnx.cursor()
print blue
print(" WELCOME TO DEVINE DINING ")
print red
print"***************************************"
print blue
print(" 1.Login")
print(" 2.Sign Up")
print(" 3.Manager Login")
print(" 4.Chef Login")
print(" 5.Quit")
print red
print("**************************************")
print reset
a=input("enter your choice:")
if a==1:
c=self.cust_login()
obj3.user(c)
elif a==2:
self.signup()
elif a==3:
m=self.managerlogin()
obj3.user(m)
elif a==4:
ch= self.chef_login()
obj3.user(ch)
elif a==5:
sys.exit(0)
else:
print("invalid choice!")
print("please enter a valid choice!")
self.customer()
def managerlogin(self):
cnx=mysql.connector.connect(user='user02',password='Tata@1234',host='127.0.0.1',database='group6')
cursor=cnx.cursor()
managerid=[]
t=[]
print("****************************************")
a=raw_input("enter the manager id of manager6:")
q=("select * from manager6 where mid=%s"%a)
cursor.execute(q)
t=cursor.fetchall()
for i in t:
for j in i:
managerid.append(str(j))
if a not in managerid:
print("the managerid doesnot exist")
self.customer()
else:
password=getpass("enter your password:")
abc=("select password from manager6 where mid=%s"%a)
cursor.execute(abc)
t=cursor.fetchall()
for i in t:
if i in t:
print("login sucessfull")
return [1,2]
else :
print ("wrong password")
self.customer()
def chef_login(self):
cnx=mysql.connector.connect(user='user02',password='Tata@1234',host='127.0.0.1',database='group6')
cursor=cnx.cursor()
chefid=[]
t=[]
print("**************************************")
a=raw_input("enter the chef id:")
q=("select * from chef6 where chefid=%s"%a)
cursor.execute(q)
t=cursor.fetchall()
for i in t:
for j in i:
chefid.append(str(j))
if a not in chefid:
print("the chefid doesnot exist")
self.customer()
else:
password=getpass("enter your password:")
abc=("select password from chef6 where chefid=%s"%a)
cursor.execute(abc)
t=cursor.fetchall()
for i in t:
if i in t:
print("login sucessfull")
return [001,3]
else :
print ("wrong password")
self.customer()
def cust_login(self):
cnx=mysql.connector.connect(user='user02',password='Tata@1234',host='127.0.0.1',database='group6')
cursor=cnx.cursor()
count=0
c=[]
print("****************************************")
loginid=raw_input("enter user id:")
q=("select userid from customer6")
cursor.execute(q)
t=cursor.fetchall()
for i in t:
for j in i:
c.append(str(j))
if loginid not in c:
print ("user does not exist")
ans1=raw_input("Do you want to signup? y/n")
if(ans1.lower()=='y'):
print("SIGN UP")
self.signup()
elif(ans1.lower()=='n'):
exit()
else:
print("invalid input")
exit()
else:
while count<3:
p1=getpass("enter password")
count=count+1
abc=("select password from customer6 where userid='%s'"%(loginid))
cursor.execute(abc)
t=cursor.fetchone()
if p1==t[0]:
print "successful login"
cursor.execute("select cid from customer6 where userid='%s'"%(loginid))
global cid
cid=int(cursor.fetchall()[0][0])
return [cid,1]
break
else:
print"wrong password"
def signup(self):
cnx=mysql.connector.connect(user='user02',password='Tata@1234',host='127.0.0.1',database='group6')
cursor=cnx.cursor()
print("welcome to devine dining!!")
print("***************************************")
name=raw_input("enter name:")
contact=raw_input("enter contact:")
address=raw_input("enter your address:")
gender=raw_input("gender:")
mailid=raw_input("enter mailid:")
userid=raw_input("enter user id of characters and atleast 1 special character:")
while(1):
password=getpass("enter password containing atleast one special character with minimum length of 8 characters:")
if len(password)<8:
print "password is less than 8 characters"
elif re.search('[!@#$%&*?]',password)is None:
print "there is no special character"
else:
count=0
while(count<3):
pd=getpass("confirm password")
if pd==password:
print "password created"
query=("insert into customer6(name,contact,address,gender,mailid,userid,password) values('%s','%s','%s','%s','%s','%s','%s')"%(name,contact,address,gender,mailid,userid,password))
cursor.execute(query)
cnx.commit()
ans=raw_input("login? y/n ")
if ans.lower()=='y':
print("LOGIN")
self.cust_login()
elif ans.lower()=='n':
print"THANK YOU"
break
else:
print("please select another option:")
self.customer()
else:
print "password does not match,retype the password"
count=count+1
# print("please select another option")
# ans=raw_input("login? y/n")
#if ans=='y':
# self.cust_login()
# elif ans=='n':
# print"thank you"
# self.customer()
if __name__=='__main__':
l=loginpage()
l.customer()