[eluser]123wesweat[/eluser]
Hi,
Need some fresh pair of eyes
the following updates the database but i don't know how to "stay" on the same url???
1/ I have a form on a dynamic page
2/ page has content from db (form not yet)
3/ form has an action="test/save"
4/ routing is enable like
Code:
//to get the right content from db
$route['test/banksy'] = "testForm/show_content/1";
$route['test/futura'] = "testForm/show_content/2";
//save form data in db
$route['test/save'] = "testForm/test";
this is my testForm -> test function
Code:
function test(){
$this->load->helper(array('form','url'));
$this->load->library("form_validation");
$this->load->model('forms/test_formc_model');
$content_id = $this->input->post('hidden_content_id');
$options = array ('content_id' => $content_id);
$data['showContent'] = $this->test_formc_model->get_content($options);
$data['hiddenContentID'] = $content_id;
$val = $this->form_validation;
$val->set_rules('fname', 'fname', 'trim|required');
$val->set_rules('lname', 'lname', 'trim|required');
$val->set_rules('item', 'item', 'trim|required');
$val->set_rules('email', 'email', 'email|required|valid_email');
if ($val->run() == FALSE) {
//show errors
$this->load->view('testfolder/view_test_mainC', $data);
} else {
//put in our DB
$res = $this->test_formc_model->insert_data();
if($res == 1) {
$this->load->view('success');
return false;
} else {
$msg = 'hmm, db off.';
}
}
}
Here's a quick example
city2go.net/test/banksy
city2go.net/test/futura
Regards,