Guest User

Untitled

a guest
Nov 28th, 2018
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. #!/usr/bin/python3
  2. import cgi
  3. import cgitb
  4. cgitb.enable()
  5.  
  6. # HTML Content - BEGIN
  7. print("<h1>User Login</h1>")
  8. data = cgi.FieldStorage()
  9. username= data['username'].value
  10. password= data['password'].value
  11.  
  12. #Confirms form data submission
  13. print("username= " + username)
  14. print(" password= " + password)
  15.  
  16. #Import Database
  17. import sqlite3
  18. conn = sqlite3.connect('/directory/path/database.db')
  19. c = conn.cursor()
  20.  
  21.  
  22. # ***WORK IN PROGRESS***
  23. for row in c.execute(f"SELECT * FROM Table WHERE username = '{username}'"):
  24. if row[1] != username:
  25. print("ERROR! No Username!")
  26. sys.exit()
  27. if row[2] != password:
  28. print("ERROR! Wrong password!")
  29. sys.exit()
  30. #***WORK IN PROGRESS***
  31.  
  32. #Display personal information
  33. print ("<h1>personal information</h1>")
  34. #HTML CONTENT - END
Add Comment
Please, Sign In to add comment