Python Forum
[Solved]Help with SQLite Login Form
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Solved]Help with SQLite Login Form
#3
(Jun-11-2022, 12:48 AM)menator01 Wrote: Add privilege to your select statement then show the correct menu occordding to the returned result.

Ok, I got that part.
(This is what I have)
        #----------------------------------
        import sqlite3
        connection = sqlite3.connect("users.db")
        cursor = connection.cursor()
                
        # cursor.execute('''
        #         insert into Users (Name, Password, Privilege)
        #         values ('Admin',1234,'admins')
        #         ''')
        cursor.execute("SELECT*FROM Users")
        print(cursor.fetchall())
        
        cursor.execute(f"SELECT Privilege from Users WHERE Name ='{userInputName}' AND Password = '{userInputPassword}';")
        connection.commit()
        privilege = cursor.fetchone()
        print("Result: ",privilege)

        if privilege == "admins":
            print("Hello admin User")
        elif privilege == "user":
            print("Hello standard user")
        else:
            print("Try again")
        
        #Close the connection
        connection.close()
        #----------------------------------
This is what it outputs if I type in Name:Bob, & Password:1234:
Output:
[(1, 'Admin', 1234, 'admins'), (2, 'Admin', 1234, 'admins'), (3, 'Bob', 1234, 'user')] Result: ('user',) Try again
Why doesn't it print("Hello standard user")?

Thanks in advance.
Reply


Messages In This Thread
[Solved]Help with SQLite Login Form - by Extra - Jun-10-2022, 11:48 PM
RE: Help with SQLite Login Form - by menator01 - Jun-11-2022, 12:48 AM
RE: Help with SQLite Login Form - by Extra - Jun-24-2022, 01:50 PM
RE: Help with SQLite Login Form - by deanhystad - Jun-24-2022, 02:17 PM
RE: Help with SQLite Login Form - by Extra - Jun-24-2022, 02:22 PM
RE: Help with SQLite Login Form - by Extra - Jun-24-2022, 02:25 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  [Solved]Help with search statement-SQLite & Python Extra 1 1,097 May-06-2022, 07:38 PM
Last Post: Extra
  in a login interface when i try login with a user supposed to say test123 but nothing NullAdmin 3 2,354 Feb-20-2021, 04:43 AM
Last Post: bowlofred

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020