from os import name
import sqlite3
import random
import time
class GirisYap:
def __init__(self,name):
self.connectDataBase()
self.name = name
self.denemehakki = 3
self.status = True
def run(self):
self.menu()
self.status = False
choice = self.choice()
if choice == 1:
self.iforgotpassword()
if choice == 2:
self.uyeol()
if choice == 3:
self.login()
def menu(self):
print("***** {} Login System ******".format(self.name))
def uyeol(self):
self.randomsayi = random.randint(1111,99999)
namesign = input("Name: ")
usernamesign = input("Username: ")
passwordsign = input("Password: ")
epostasign = input("E-Mail: ")
self.cursor.execute("INSERT INTO deger VALUES('{}','{}','{}','{}','{}')".format(namesign,usernamesign,passwordsign,self.randomsayi,epostasign))
print("User registered as {} , {} , {} , {} , {}".format(namesign,usernamesign,passwordsign,self.randomsayi,epostasign))
self.connect.commit()
time.sleep(2)
exit()
def choice(self):
while True:
try:
select = int(input("1-I forgot my password\n2-Sign İn\n3q-Log İn\nChoice: "))
if select < 1 or select > 2:
print("Incorrect Login! Try Again!")
continue
break
except ValueError:
print("Enter Numbers Not Letters!")
return select
def login(self):
while True:
self.username = input("Username: ")
self.password = input("Password: ")
self.cursor.execute("SELECT * FROM deger WHERE kullaniciadi = '{}' AND parola = '{}'".format(self.username,self.password))
data = self.cursor.fetchone()
if data:
print("User {} Join!".format(data[0]))
break
else:
self.denemehakki -= 1
print("Error! Username is Password is Wrong! Right to try: " + str(self.denemehakki))
if self.denemehakki == 0:
print("You have no rights, the program is closing")
exit()
def iforgotpassword(self):
self.eposta = input("E-Mail: ")
self.cursor.execute("SELECT * FROM deger WHERE eposta = '{}' ".format(self.eposta))
data = self.cursor.fetchone()
if data:
print("Send Activate Mail...")
from smtplib import SMTP
randomsayi = random.randint(1111,9999)
try:
message = "Activate Code: " + str(randomsayi)
subject = "Activate Code"
content = "Subject: {0}\n\n{1}"
myMailAdress = "eposta"
password = "sifre"
sendTo = data[4]
mail = SMTP("smtp.gamil.com", 587)
mail.ehlo()
mail.starttls()
mail.login(myMailAdress,password)
mail.sendmail(myMailAdress, sendTo, content.encode("utf-8"))
print("Mail sent to {}".format(data[4]))
while True:
loginprocess = int(input("Actiate Code: "))
if loginprocess == randomsayi:
print("Activate Code is True! Your Password: {}".format(data[2]))
break
else:
print("Activate Code is False! Try Again!")
except Exception as e:
print("Error! Error Code: {}".format(e))
else:
print("There is no such email in the system!")
time.sleep(5)
def connectDataBase(self):
self.connect = sqlite3.connect("deger.db")
self.cursor = self.connect.cursor()
self.cursor.execute("CREATE TABLE IF NOT EXISTS deger(isim TEXT,kullaniciadi,parola,id,eposta)")
self.connect.cursor()
girisyap = GirisYap("Deneme")
while girisyap.status:
girisyap.run()
gamil ne yeniyo mu ?
Bune yeni farkettim eyvallah