[eluser]smnirven[/eluser]
Hello all,
I am having a problem loading a view within one of my controllers. Basically, I have an insert function that is the handler for a form of mine. Inside the insert function I check that the posted values from the form are not null or blank. If I find a required field that is null or blank, I want to return to the form and pass it an error message to display on the form. Here is the code that is not working:
Code:
// First check required fields
if (!isset($_POST['noteSubject']) || $_POST['noteSubject'] == '')
{
$sql = "INSERT INTO debug_info (text, timestamp) VALUES ('WTF1', NOW())";
$this->db->query($sql);
$data['error'] = "Subject is a required field";
$this->load->view('create_note_view', $data);
}
$sql = "INSERT INTO debug_info (text, timestamp) VALUES ('WTF2', NOW())";
$this->db->query($sql);
When I submit the form without entering anything into the 'noteSubject' field, it never makes it back to the form (create_note_view) like I wanted. Also, when I look at my debug_info table, I see both the "WTF1" and "WTF2" message. Can anyone explain this and help me out how to fix this?
Thanks!