CodeIgniter Forums
Why does routing fail? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=31)
+--- Thread: Why does routing fail? (/showthread.php?tid=81609)



Why does routing fail? - yoshi - 03-26-2022

Hi. Smile

## overview
I'm trying to make `$ routes-> get` and` $ routes-> post` on the update screen, but the routing that receives the id doesn't work.
Especially the second post method output "` Undefined array key 0`
https://drive.google.com/file/d/1QnEnUe9ceiQxjoop7_kYhW60Faz7DSls/view?usp=drivesdk

What may be the cause?
Commenting out `$ routes-> post` will display the get method successfully.

## reference
https://ci-trans-jp.gitlab.io/user_guide_4_jp/incoming/routing.html

PHP Code:
$routes->get('school/certification/edit/(:num)''SchoolCertificationController::editGet/$1', ['as' => 'certification_edit_get']);
// TODO: For some reason I get an Undefined array key 0 when I add this
$routes->post('school/certification/edit/(:num)''SchoolCertificationController::editPost/$1', ['as' => 'certification_edit_post']); 



RE: Why does routing fail? - kenjis - 03-26-2022

It seems no problem in your route definitions.
Did you send post request to the URL like http://localhost/school/certification/edit/1 ?

But I recommend you to read the latest official user guide.
https://codeigniter4.github.io/userguide/
Your reference is too old, and not the official.


RE: Why does routing fail? - yoshi - 03-26-2022

(03-26-2022, 03:28 AM)kenjis Wrote: It seems no problem in your route definitions.
Did you send post request to the URL like http://localhost/school/certification/edit/1 ?

But I recommend you to read the latest official user guide.
https://codeigniter4.github.io/userguide/
Your reference is too old, and not the official.
thanks, kenjis Smile
I will read new document.