[eluser]esingley[/eluser]
Hello!
I've been doing PHP development for a while but am new to MVC and am trying to get my head around the basic concepts. Here's what I'm doing now: I have a form that when submitted will insert the form data into a DB, redirect back to the original form, but this time with a "Information saved." message at the top.
So, I've got something like this in my Controller:
Code:
class My_Controller extends Controller {
function My_Controller()
{
parent::Controller();
$this->load->helper('url');
}
function index()
{
$data['save_msg'] = "";
if ($this->uri->segment(3) == "s") {
$data['save_msg'] = "Information saved.";
}
$template['main_content'] = $this->load->view('invoice_view', $data, true);
$this->load->view('main_template_view', $template);
}
function save()
{
// some code to insert data into DB will go here, then on successful insertion:
redirect('invoice/index/s');
}
}
But this leaves with with 1. a funny URL after saving and 2. the thought that there's probably a better way to do this.
Is there? I know this is basic, but I want to get these basics down before I move on!
Thanks for the help!
~ Eric