https://github.com/arkenidar/php_login_system
php login system with redbean
https://github.com/arkenidar/php_login_system
php redbean
Last synced: about 1 month ago
JSON representation
php login system with redbean
- Host: GitHub
- URL: https://github.com/arkenidar/php_login_system
- Owner: arkenidar
- Created: 2025-02-28T19:45:02.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-02-28T20:44:50.000Z (over 1 year ago)
- Last Synced: 2025-02-28T23:24:15.862Z (over 1 year ago)
- Topics: php, redbean
- Language: PHP
- Homepage:
- Size: 129 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
I'd be happy to create a login system using RedBeanPHP! RedBeanPHP is a great ORM (Object-Relational Mapper) for PHP that makes database interactions simple and intuitive. Let me create a complete login system for you using RedBeanPHP.
I've created a complete login system using RedBeanPHP for you! The system includes user registration, login, and session management functionality.
## What I've Created
1. **Core Login System** (`login_system.php`):
- Database connection setup with RedBeanPHP
- User registration with validation
- Secure password hashing
- Login functionality
- Session management
- Helper functions for checking login status
2. **HTML Templates**:
- `register.php`: User registration form
- `login.php`: Login form
- `dashboard.php`: Protected page for logged-in users
- `logout.php`: Handles logging out
## How to Set Up
1. **Install RedBeanPHP** using Composer:
```
composer require gabordemooij/redbean
```
2. **Configure the Database**:
- In the `setupDatabase()` function, update the database credentials:
```php
R::setup('mysql:host=localhost;dbname=login_system', 'username', 'password');
```
3. **File Structure**:
- Save the first code block as `login_system.php`
- Save the HTML templates as their respective filenames
- Make sure all files are in the same directory
## Security Features
- Passwords are securely hashed using PHP's `password_hash()` with the default algorithm
- Protection against SQL injection through RedBeanPHP's parameterized queries
- Input validation on registration and login
- Consistent error messages that don't reveal whether a username exists
- Session management for authenticated users
## Development vs. Production
- During development, RedBeanPHP will automatically create tables and columns as needed
- For production, you should set `R::freeze(true)` to prevent database structure modifications
This system provides a solid foundation that you can easily extend with additional features like password reset, email verification, or user roles.