https://github.com/stdakov/php_flash_messages
https://github.com/stdakov/php_flash_messages
Last synced: 7 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/stdakov/php_flash_messages
- Owner: stdakov
- License: mit
- Created: 2024-11-28T08:27:33.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2024-11-28T10:29:04.000Z (11 months ago)
- Last Synced: 2025-02-08T10:47:08.974Z (9 months ago)
- Language: Dockerfile
- Size: 4.88 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# PHP FLASH messages
This is supper simple implementation of php flash messages
## Installation
The preferred way to install this tool is through [composer](http://getcomposer.org/download/).
Either run
```
php composer.phar require stdakov/flash
```
or add
```
"stdakov/flash": "*"
```
## Usage
set message:
```php
require 'vendor/autoload.php';
session_start();
use Dakov\FM;
if (isset($_POST['username']) && isset($_POST['password'])) {
$user = getUser($_POST['username']);
if ($user != null && isset($user['id']) && password_verify($_POST['password'], $user['password'])) {
$_SESSION["USER"] = $user['id'];
$hour = time() + 3600 * 24 * 365;
setcookie('user_id', $user['id'], $hour);
} else {
FM::set("wrong_credentials", "Invalid credentials");
}
header("Location: /");
}
```
use the message:
```html
= FM::flash("wrong_credentials"); ?>
```
The MIT License (MIT)