Vinston Benith
Vinston Benith

Reputation: 21

form submit redirecting to index page of codeigniter

When clicking my submit button of the form the page is redirecting to the index page i.e the welcome message of codigniter. but the url shows the requested page. . I m confused.

view page:

<form action='welcome/register' method='post'>
<table>......
......
</form>

and in controller page i ve done the validation and if validation fails it have to redirect to register_new page but the redirected page is the welcome page of codeignitor. . But no problem with the url.

Upvotes: 0

Views: 2094

Answers (1)

cjds
cjds

Reputation: 8426

This is how you use forms in CodeIgniter. Don't try to use HTML forms like that, just use CodeIgniter style

http://ellislab.com/codeigniter/user-guide/helpers/form_helper.html

Add this to your controller (to load the form helper):

$this->load->helper('form');

In your view

<?php echo form_open('controllername/functionname');?>
     <input type ...>
     //...more inputs
</form>

It redirects to the original page if action is not specified. It shouldn't redirect to the index page ever unless specified by second controller.

Upvotes: 2

Related Questions