Download the PHP package ideaglory/flash without Composer
On this page you can find all versions of the php package ideaglory/flash. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package flash
Flash Message PHP Class
Manage Notifications, Errors, and Form Values with Sessions
A lightweight PHP utility for managing flash messages, form validation errors, and posted form values using PHP sessions.
Flash messages are temporary notifications (e.g., success, warnings, errors) displayed to users after an action, and are automatically cleared after a page reload. This class also supports form validation error handling and repopulating form fields with previously submitted values.
Features
- Flash messages: Supports multiple message types (
success
,danger
,warning
,info
). - Validation errors: Easily manage and display form validation errors.
- Form repopulation: Automatically sanitize and repopulate submitted form values.
- Session-based: Leverages PHP sessions for temporary storage and clears data after being displayed.
- XSS protection: Sanitizes input values to prevent cross-site scripting (XSS).
Installation
You can install this package via Composer. Run the following command:
Usage
1. Setting Flash Messages
You can set success, warning, danger, or info messages.
Output:
2. Handling Form Validation Errors
Store validation errors and repopulate form inputs.
Output:
3. Displaying Mixed Notifications
Set and display multiple types of messages in a single request.
Output:
4. Clearing and Reusing Flash Data
The class automatically clears session data after being displayed, but you can set new data for the next request.
First Page Output:
Next Page Output:
5. Preventing Cross-Site Scripting (XSS)
The class sanitizes all posted values using htmlspecialchars
to prevent malicious input.
Output:
License
This project is licensed under the MIT License. Feel free to use and modify it as needed.
Author
Created by IdeaGlory.