| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
This project implements a simple login and registration system with basic security using PHP and MySQL. It is designed to be beginner-friendly, providing a step-by-step guide to creating robust forms, handling user authentication, managing sessions, validating inputs, and interacting securely with a MySQL database.
This system is based on the tutorials "Secure Login System with PHP and MySQL" and "Secure Registration System with PHP and MySQL".
XAMPP is recommended for local development as it includes PHP, MySQL, Apache, and phpMyAdmin.
Create a Database:
Create accounts Table: Execute the following SQL query in your phplogin database:
CREATE TABLE IF NOT EXISTS `accounts` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`username` varchar(50) NOT NULL,
`password` varchar(255) NOT NULL,
`email` varchar(100) NOT NULL,
`registered` datetime NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;The article also includes a test account. If you wish to add it:
INSERT INTO `accounts` (`id`, `username`, `password`, `email`, `registered`) VALUES (1, 'test', '$2y$10$SfhYIDtn.iOuCW7zfoFLuuZHX6lja4lF4XA4JqNmpiH/.P3zB8JCa', 'test@example.com', '2025-01-01 00:00:00');
-- Note: The password 'test' is hashed. The registration form should handle hashing for new users.Clone or Download: Place the project files in your web server's document root (e.g., htdocs/phplogin if using XAMPP).
Configure Database Connection: Open the following PHP files and update the database connection variables to match your MySQL setup:
<?php
// In authenticate.php, profile.php, etc.
$DATABASE_HOST = 'localhost';
$DATABASE_USER = 'your_mysql_username'; // e.g., 'root'
$DATABASE_PASS = 'your_mysql_password'; // e.g., '' or your root password
$DATABASE_NAME = 'phplogin'; // The database name you created
$con = mysqli_connect($DATABASE_HOST, $DATABASE_USER, $DATABASE_PASS, $DATABASE_NAME);
if (mysqli_connect_errno()) {
exit('Failed to connect to MySQL: ' . mysqli_connect_error());
}
// ... rest of the code
?>Start Your Web Server: Ensure Apache and MySQL services are running from your XAMPP control panel (or equivalent).
Access the Application: Open your web browser and navigate to http://localhost/phplogin/ (or the appropriate path if you named the folder differently).
The original article highlights several important security practices:
David Adams - info@codeshack.io
GitHub: https://github.com/codeshackio/basic-php-login-registration-system
X (Twitter): https://twitter.com/codeshackio
| Back | FazBrowse Home | New Git URL |