I am new to slim my goal is to create a basic environment of development from slim
and it’s been several days that I block on the request in bdd, my configuration is good
in most of the examples the request is done directly in the function, but I prefer to use a class action for CRUD operations.
I would like to know or have a documentation for my test on how to send my form data in POST to work then in my class
(I am forced to use the path_for () method
and the function setName) and add twigExtension?
thank you for your help really
I noticed the following things:
- You should use the correct key in your
$data array. e.g.
$name = $data['name'];
- Warning: There is a sql injection point in your code example. Don’t interpolate SQL with variables. Use prepared statements instead.
- Don’t overwrite the
$ret. Remove this line
$response = $req;
hello odan, thank you for the advice I will rectify immediately
thank you very much
Hi you should add the following:
To make full used of slim4 restful options:
//BY adding the below in your forms you can hit any of the above http requests
<input type ="hidden" name ="_METHOD" value ="DELETE">
hello thank you for your return
and for example is it possible to activate the method delete for example by a simple link href?
Hi, No it wont as an href link is a normal get request.
What you could do is use jquery onclick event and post with ajax to that url with delete and just reload the page when done.
You can also use the any option and add a extra param
if you want to use a link
ok thank you I understand thank you very much