[PHP-NOTES] note 130802 added to reserved.variables.post
[email protected] ("Dizzy@wipssy") Wed, 03 Jun 2026 21:46:04 +0000
| Newsgroups | php.notes |
|---|---|
| Message-ID | <[email protected]> |
We can use POST to get params like this:
<?php
namespace App\Controllers;
use App\Classes\Championship;
use App\Models\ChampionshipModel;
class ChampionshipController
{
public function index() {
$data = ChampionshipModel::index();
include_once 'app/View/principal.php';
}
public function show(int $id) {
$championship = ChampionshipModel::show($id);
$teams = ChampionshipModel::teamsByChampionship($id);
include_once 'app/View/detail.php';
}
public function create() {
include_once 'app/View/createChampionship.php';
}
public function store() {
if (empty($_POST['name'])) {
$error = "Name is required";
include_once 'app/View/createChampionship.php';
return;
}
if (empty($_POST['date'])) {
$error = "Date is required";
include_once 'app/View/createChampionship.php';
return;
}
if (empty($_POST['total_prize'])) {
$error = "total prize is required";
include_once 'app/View/createChampionship.php';
return;
}
try {
$championship = Championship::createChampionshipFromArray($_POST);
ChampionshipModel::store($championship);
header('Location: /');
exit;
} catch (\Exception $e) {
$error = $e->getMessage();
include_once 'app/View/createChampionship.php';
}
}
}
----
Server IP: 206.189.2.9 (proxied: BunnyCDN)
Probable Submitter: 79.117.169.52
----
Manual Page -- https://php.net/manual/en/reserved.variables.post.php
Edit -- https://main.php.net/note/edit/130802
Del: integrated -- https://main.php.net/note/delete/130802/integrated
Del: useless -- https://main.php.net/note/delete/130802/useless
Del: bad code -- https://main.php.net/note/delete/130802/bad+code
Del: spam -- https://main.php.net/note/delete/130802/spam
Del: non-english -- https://main.php.net/note/delete/130802/non-english
Del: in docs -- https://main.php.net/note/delete/130802/in+docs
Del: other reasons-- https://main.php.net/note/delete/130802
Reject -- https://main.php.net/note/reject/130802
Search -- https://main.php.net/manage/user-notes.php