Welcome Guest, Not a member yet? Register   Sign In
MVC And Form Submission Best Practice
#1

[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. Smile Is there? I know this is basic, but I want to get these basics down before I move on!

Thanks for the help!

~ Eric


Messages In This Thread
MVC And Form Submission Best Practice - by El Forum - 10-31-2007, 06:19 PM
MVC And Form Submission Best Practice - by El Forum - 10-31-2007, 06:26 PM
MVC And Form Submission Best Practice - by El Forum - 10-31-2007, 06:42 PM
MVC And Form Submission Best Practice - by El Forum - 10-31-2007, 06:45 PM
MVC And Form Submission Best Practice - by El Forum - 11-01-2007, 12:58 AM
MVC And Form Submission Best Practice - by El Forum - 11-01-2007, 01:44 PM



Theme © iAndrew 2016 - Forum software by © MyBB