Form Actions in Codeigniter gets added to the exis

2019-08-17 03:59发布

I am new to codeigniter and i am facing a small issue. I have a controller named "test" and would like to call the "edit_details" action within that controller. This is a test application i am developing. I would like to update a user's information and i am sending the user id via(URL segments) the URL: "http://localhost/codeigniter/index.php/test/edit/12" as an example. The edit action loads the view with a form where the user's details could be entered. This is done using an anchor from the view(an edit link next to each record). Anchor: "test/edit/$row->id". Everything so far works great.

The problem is when i submit the form with the action 'test/update_details', the url then becomes "http://localhost/codeigniter/index.php/test/edit/test/update_details'". The edit_details action loads a model which then does the database stuff. The id is sent using a hidden field in the view.

I am not sure what is going wrong here. The URL doesnt seem to change when i make calls to a controller. It either stays the same or gets appended to the existing URL. I have tried google to search for a solution but couldnt find any.

I still havent removed my index.php as this is a test application. My base url in the config file is : "http://localhost/codeigniter/" Autoloaded helpers are: form and url Autoloaded libraries are: database

Thanks in advance.

1条回答
Anthone
2楼-- · 2019-08-17 04:37

It sounds like you need to pass the form back using the base_url(). In other words:

http://localhost/codeigniter/index.php/test/edit/test/update_details

is wrong. I believe you are really trying to pass the edit view details to:

http://localhost/codeigniter/index.php/test/update_details

via submit, your url is getting messed up. Your form_open should look like this:

echo form_open(base_url()."test/update_details");
查看更多
登录 后发表回答