A simple and secure PHP authentication system with modern gradient UI design. This project provides user registration, login functionality, and session management with MySQL database integration.
- 🔐 Secure Authentication - User login and registration with session management
- 👤 User Management - Dashboard with user information display
- 🎨 Modern UI Design - Professional gradient interface with responsive layout
- 📱 Mobile Responsive - Works seamlessly on all device sizes
- 🗄️ MySQL Database - Reliable data storage and management
- 🔒 Session Security - Protected routes and secure user sessions
- PHP >= 8.2
- MariaDB >= 10.4 (or MySQL >= 5.7)
- Apache >= 2.4
- XAMPP 8.2.12 (recommended for local development)
- PHP Extensions: mysqli, curl, mbstring
git clone https://github.com/galangam/php-login-system.git
cd php-login-systemCreate a new MySQL database:
CREATE DATABASE buku_tamu;Import the database schema:
USE buku_tamu;
CREATE TABLE users (
id INT AUTO_INCREMENT PRIMARY KEY,
username VARCHAR(50) NOT NULL UNIQUE,
password VARCHAR(255) NOT NULL,
nama VARCHAR(100) NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);Copy the example configuration file:
cp service/database.example.php service/database.phpEdit service/database.php with your database credentials:
<?php
$hostname = "localhost";
$username = "root";
$password = "your_password";
$database_name = "buku_tamu";
$db = mysqli_connect($hostname, $username, $password, $database_name);
if($db->connect_error){
echo "koneksi database rusak";
die("error!");
}
?>If using XAMPP:
- Move the project folder to
htdocsdirectory - Start Apache and MySQL from XAMPP Control Panel
- Open browser and navigate to:
http://localhost/php-login-system
php-login-system/
├── layout/
│ ├── header.html # Header component with navigation
│ └── footer.html # Footer component
├── service/
│ ├── database.php # Database configuration (ignored)
│ └── database.example.php # Example database config
├── index.php # Home page
├── login.php # Login page
├── register.php # Registration page
├── dashboard.php # User dashboard (protected)
├── halo.php # Welcome page
├── nama.php # User info page
├── date.php # Date display page
├── style.css # Main stylesheet
├── .gitignore # Git ignore rules
└── README.md # Documentation
- Navigate to the registration page
- Fill in username, password, and name
- Click "Register" button
- You will be redirected to login page
- Enter your username and password
- Click "Login" button
- Upon successful login, you'll be redirected to the dashboard
- View your user information
- Access protected pages
- Logout functionality
- Password hashing (recommended to implement
password_hash()) - Session-based authentication
- Protected routes with session checks
- SQL injection prevention (use prepared statements)
- XSS protection
Edit style.css to customize the gradient colors:
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);- Edit
layout/header.htmlfor navigation changes - Edit
layout/footer.htmlfor footer customization
- Implement password hashing with
password_hash() - Add password reset functionality
- Email verification system
- User profile editing
- Remember me functionality
- Admin panel
- Input validation improvements
- Prepared statements for SQL queries
- CSRF protection
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the project
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
@galangam
- GitHub: @galangam
- Design inspiration from modern web applications
- PHP and MySQL community
- Open source contributors
If you have any questions or issues, please open an issue on GitHub or contact me directly.
⭐ Star this repository if you find it helpful!