-
Notifications
You must be signed in to change notification settings - Fork 0
/
login.py
42 lines (34 loc) · 1.02 KB
/
login.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
import mysql.connector
mydb=mysql.connector.connect(host='localhost',user='root',password='nandhaaku',database='eShop')
mycursor=mydb.cursor()
def login():
n = input('Username: ')
p = input('Password: ')
mycursor.execute('SELECT * FROM customers WHERE name = %s AND password = %s', (n, p))
data=mycursor.fetchone()
if data:
print("Welcome to eShop !")
from order import order
order(n)
else:
print('Invalid id or password')
e = input('Press y to register: ')
if e == 'y':
mycursor.execute('insert into customers(name,password) values(%s,%s)',(n,p))
mydb.commit()
print('Your Id and password is registered !')
from order import order
order(n)
else:
print('Have a nice day!')
def admin():
n = input('Username: ')
p = input('Password: ')
mycursor.execute('SELECT * FROM admin WHERE name = %s AND pass = %s', (n, p))
data=mycursor.fetchone()
if data:
print("Welcome admin !")
from admin import ad
ad()
else:
print('Invalid id or password')