Is there a specific way to code a database authentification for users of a program?
DragonMastur 23 Light Poster
What your asking sound a lot like what Im making right now. here is what I have so far...
Note: If you run the program you will have to make some .txt file and change the directories.
import time
i = ""
fileContents = ""
#User 1
password1 = "hellomynameis"
username1 = "DragonMastur"
#User 2
password2 = "michael"
username2 = "aiden"
#User 3
password3 = "..........."
username3 = "..........."
line = "A line looks."
class Book:
def readBook(self, line):
print "Fetching Book..."
file = open('/home/pi/BookFolder/book.txt', mode='r')
time.sleep(1)
print "Done"
time.sleep(1)
print "\n\n\n"
while line != "":
line = str(file.readline())
print line
print "\n\n\n"
def readBook2(self, line):
print "Fetching Book..."
file = open('/home/pi/BookFolder/book2.txt', mode='r')
time.sleep(1)
print "Done"
time.sleep(1)
print "\n\n\n"
while line != "":
line = str(file.readline())
print line
print "\n\n\n"
def readBook3(self, line):
print "Fetching Book..."
file = open('/home/pi/BookFolder/book3.txt', mode='r')
time.sleep(1)
print "Done"
time.sleep(1)
print "\n\n\n"
while line != "":
line = str(file.readline())
print line
print "\n\n\n"
def __init__(self):
i = "Input from the user."
while True:
print 'Enter Your Username: '
u = raw_input()
if u == username1 or u == username2 or u == username3:
print "Enter Your Password: "
p = raw_input()
if p == password1 and u == username1 or p == password2
and u == username2 or p == password3 and u == username3:
while i != "q" or i != "Q":
print "-------Menu-------"
print "Look at book 1"
print "Quit Q"
i = raw_input()
if i == "1":
if u == username1:
self.readBook(line)
elif u == username2:
self.readBook2(line)
elif u == username3:
self.readBook3(line)
else:
print "ERORR!!!!!!!!!!!!"
elif i == "q" or i == "Q":
quit(0)
else:
print "Sorry...That is not Avalible."
else:
print "Incorrect password."
print "Q = Quit\nP = Try again."
i = raw_input()
if i == "q" or i == "Q":
quit(0)
elif i != "P" or i != "p":
print "Sorry not avalible... Quiting..."
time.sleep(5)
quit(0)
else:
print "Incorrect Username."
print "Q = Quit\nU = Try again."
i = raw_input()
if i == "q" or i == "Q":
quit(0)
elif i != "u" or i != "U":
print "Sorry not avalible... Quiting..."
time.sleep(5)
quit(0)
elif i == "u" or i == "U":
pass
if __name__ == "__main__":
Book()
print "Good Bye! See you later!"
time.sleep(5)
DragonMastur 23 Light Poster
Yes I have my username and password in there but that is for my raspberry pi. Not any of my other acounts.
Andrae 0 Newbie Poster
Thank you for sharing that code you gave me an idea of what i can do.
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.