Login

Please fill in your details to login.





login (simple version)

A simple Python login system.
Very simple login script - requires a 'csv' file with usernames and passwords and the 'csv.py' module. Note that this script uses no security! All the usernames and passwords are stored in plain-text in the csv file. Neither does it give you more than one chance to login, but it's not that difficult to break.

import sys
import csv

loggedin = False
users = csv.csv2sequence('users.csv')

username = input('Enter username : ')
password = input('Enter password : ')

for user in users:
    if username == user[0] and password == user[1]:
        loggedin = True
        break

if loggedin:
   print('Success - you are logged in as \'{0}\'.'.format(username))
else:
   print('Incorrect username or password.')
   sys.exit()

# Rest of program goes here ...

print('This is the rest of the program ...')


I've provided a copy of this Python script, the csv.py library and the users.csv file containing the sample usernames and passwords. Fill your boots.

Files

filetype
1.1 KiB
filetype
514.0 B
filetype
88.0 B
Last modified: March 20th, 2023
The Computing Café works best in landscape mode.
Rotate your device.
Dismiss Warning