1
I’m having a hard time solving a mistake that’s been slim framework
. I have a contact page that is accessed /p/contact, after accessing and clicking the send button, it tries to send the <form>
via POST to the action="" only it returns me:
Method not allowed.
Method not allowed. Must be one of: GET
I guess it’s because he’s thinking it’s GET and I’m sending the form via post.
The route configures, which is calling the view is :
$this->get('/p/{pag_slug}', function($req, $res, $args) {
$Paginas = (new \App\Models\Pagina);
$paginas = $Paginas::orderBy('ordem', 'ASC')->get();
$Informacao = (new \App\Models\Informacao);
$info = $Informacao::first();
if ($args['pag_slug'] == 'contato') {
return $this->view->render($res, 'site/contato.twig', [
'paginas' => $paginas,
'info' => $info,
]);
}
$pagina = $Paginas::where('slug', $args['pag_slug'])->first();
if ($pagina) {
return $this->view->render($res, 'site/pagina.twig', [
'paginas' => $paginas,
'pagina' => $pagina,
'info' => $info,
]);
}
})->setName('site.pagina');
What I need is to get the data entered in the form via post to the url /p/contact
Friend worked rsrs. Thanks. Just not working
$req->post()
... If I leave him, he’s error 500. I traded for$form = $req->getParsedBody();
– Alisson Acioli
That’s right, the method
post
existed until version 2. In version 3 you can usegetParsedBody
orgetParam
. For example:$name = $req->getParam("name");
– Woss