Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python3
- import cgi
- import cgitb
- cgitb.enable()
- # HTML Content - BEGIN
- print("<h1>User Login</h1>")
- data = cgi.FieldStorage()
- username= data['username'].value
- password= data['password'].value
- #Confirms form data submission
- print("username= " + username)
- print(" password= " + password)
- #Import Database
- import sqlite3
- conn = sqlite3.connect('/directory/path/database.db')
- c = conn.cursor()
- # ***WORK IN PROGRESS***
- for row in c.execute(f"SELECT * FROM Table WHERE username = '{username}'"):
- if row[1] != username:
- print("ERROR! No Username!")
- sys.exit()
- if row[2] != password:
- print("ERROR! Wrong password!")
- sys.exit()
- #***WORK IN PROGRESS***
- #Display personal information
- print ("<h1>personal information</h1>")
- #HTML CONTENT - END
Add Comment
Please, Sign In to add comment