Form submission not picking up URL route |
Hello ,
I have created a route for my admin sign in page as described below : Code: $routes->get('/control_panel/request_access', "Admin_portal\Access_control::grant_access"); From the above you can see that i have a folder "Admin_portal" in my controller folder where I have an "Access_control" controller. When I visit the URL http://localhost/site_root/public/control_panel/request_access my page loads , however when I submit a form with the same URL as my action value , I get the error below : 404 - File Not Found Controller or its method is not found: App\Controllers\Control_panel::request_access Below is my Sign in page : Code: <form action="http://localhost/bytepixels/public/control_panel/request_access" method="POST" > Any help will be appreciated. P.S : Any suggestions for a CI4 book out there ? , the documentation isn't as helpful as the ones for CI 2 & 3, not a dig at the contributors , just seeking help.
$routes->get() will only work for GET request. To define a route for a POST request you need to define it with $routes->post(). See https://codeigniter4.github.io/userguide...-in-routes
CodeIgniter 4 tutorials (EN/FR) - https://includebeer.com
/*** NO support in private message - Use the forum! ***/
PHP Code: $routes->get('products', 'Product::feature'); Multiple method: PHP Code: $routes->match(['get', 'put'], 'products', 'Product::feature'); No method: PHP Code: $routes->add('journals', 'App\Blogs'); Your form sends POST request while your route is taking get requests. pro novice
|
Welcome Guest, Not a member yet? Register Sign In |