form POST to same page, request method remains GET |
I'm trying to post a form to the current page and process it there. To this end I addes a matched route to Routes.php:
PHP Code: $routes->match(['get', 'post'], 'klanten/(:segment)', 'Klanten::bewerk/$1'); I do not have a route set up that overwrites this route. Here is the full routes list: PHP Code: $routes->match(['get', 'post'], 'soorten/(:segment)', 'Soorten::index/$1'); When I post the form somehow the request method keeps coming back as get instead of post... Here is my form HTML: Code: <form action="/klanten/<?= esc($klant['slug']) ?>/" method="post"> As you can see, I do have the forms method as post. The debug bar does show the route is there: Image doesn't work, here is the link: http://development.medicalcrossteam.nl/i...ns-get.png By now I'm ready to smash my head against the wall, because I can't figure out what is going on here. I'm hopinh you guys can help me and prevent me from doing that ![]()
I think you need to remove the trailing slash on this line:
PHP Code: <form action="/klanten/<?= esc($klant['slug']) ?>/" method="post"> Like this: PHP Code: <form action="/klanten/<?= esc($klant['slug']) ?>" method="post"> Because CI uses regex to match the routes and I think you won't get a match with a trailing slash. The user guide gives this example: Quote:
Thanks! I have been working at this problem for the better part of a day and couldn't figure it out. And one removing little slash was all it took! One this is for sure..... I'm not going to forget this one ever again!
Yeah it sucks when that happen. Regex can be a pain to use, even when we don't know we're using them!
![]()
Yeah! I tried CI a while back because of it's ease of use and the fact that it's not filled with "everything you ever might, maybe, someday, perhaps might want to use. It does what you need it to do. If it doesn't? You can still add other libraries to it.
For me as a new user, plus someone who's been out of the php scene singe 2014 and just now coming back into it, there are still headache moments over simple stuff like this ;-) |
Welcome Guest, Not a member yet? Register Sign In |