Hi,
I am getting an error about it being bad practice to access super global directly on these three functions. How should I rewrite them?
public function delete()
{
$this->jokesTable->delete($_POST['id']);
header('location: /joke/list');
}
public function saveEdit()
{
$joke = $_POST['joke'];
$joke['jokedate'] = new \DateTime();
$joke['authorId'] = 1;
$this->jokesTable->save($joke);
header('location: /joke/list');
}
public function edit()
{
if (isset($_GET['id'])) {
$joke = $this->jokesTable->findById($_GET['id']);
}
$title = 'Edit joke';
return ['template' => 'editjoke.html.php',
'title' => $title,
'variables' => [
'joke' => $joke ?? null
]
];
}
Cheers.
Mike