If you’re designing a website, and don’t want to use social logins, but at the same time, don’t know how to create a login system, this post will show you the easy way out 🙂 .
Luckily for you, one of the thing I like doing is using SQLite, and one of the projects I’m working on is a website login system written in PHP that uses SQLite. You can check out the GitHub Repo to learn more about it.
Things you should know
This is a simple script, and is likely to break as I’m still working on it. It can work, but it’s not ready for production websites yet. But, if you’d like to focus your efforts on other things and need a login system for that, this script will help.
What is it?
I created a single PHP file that does all of the following:
- Passwords are salted and hashed
- Email verification is done by sending an email with a link
- Password changes
- Username changes
- Emails and usernames must be unique
The reason I made it a single file was to make it really easy to deploy. Just make sure you have sqlite support with PHP, which you can install on Ubuntu with:
sudo apt install php-sqlite3
If you’re too lazy to read the readme file, here’s the installation part:
wget https://raw.githubusercontent.com/NerdOfLinux/SQLite-Web-Login/master/index.php -O account.php sqlite3 .ht.users.db
CREATE TABLE pending (code TEXT UNIQUE NOT NULL,username TEXT UNIQUE NOT NULL, email TEXT UNIQUE NOT NULL, password TEXT NOT NULL); CREATE TABLE users (username TEXT UNIQUE NOT NULL, email TEXT UNIQUE NOT NULL, password TEXT NOT NULL);
After doing so, edit the
account.php file, and change the following line:
with your real domain, including subdomain.
Test it out
Go to https://yourdomain.com/account.php and test out signing up, verifying your email, and updating your password.
At the time of writing, you still can’t change your email address, but I’m working on that. There is also no support for two-factor logins, although I might add that later on if it’s a feature people want. Please do NOT use this on a site that processes critical information as I don’t sanitize user input yet, so there is a chance of SQL injections.