Welcome Guest, Not a member yet? Register   Sign In
Am I doing this wong?
#1

[eluser]pdxbenjamin[/eluser]
I've used CI for awhile now and this always bugged me.

In the View a simple form...

Code:
<form action="form_do" method="post">
<input type="text" name="item" />
<input type="submit" value="Submit" />
</form>


And in the Controller...

Code:
function form_do()
{
  // form processing and whatnots

  // THEN I ALWAYS DO THIS

     $data['main_content'] = 'index';
     $this->load->view('includes/template', $data);
}


But whenever I do a form processing action the url that is returned is going to be http://site.com/controller/form_do/
even though I'm actually still on 'index' for this example.
Is this correct or am I just not getting it?
#2

[eluser]CroNiX[/eluser]
Use the form helper, form_open('controller/segment');, or, DON'T use a relative path in your form action (or css asset, or image, or javascript, or.... Relative paths get appended to the end of the current URL, but that's just a regular HTML issue.

Code:
echo form_open('form_do');
or
Code:
<form action="<?php echo site_url('form_do'); ?>" method="post">




Theme © iAndrew 2016 - Forum software by © MyBB