I am unsure what would be the best way to implement a success message into a different div.
I also am getting the error div loaded into my view when the page is loaded why? I want it to show if only if there as an error.
If there is no error how could I change the div and include a success message?
View:
<div class="alert alert-error">
<?php echo validation_errors();?>
</div>
Controller:
if($this->form_validation->run() === TRUE)
{
$userData = array(
'fName' => $this->input->post('userFirstName', TRUE),
'lName' => $this->input->post('userLastName', TRUE),
'email' => $this->input->post('userEmail', TRUE),
'password' => sha1($this->input->post('userPassword', TRUE))
);
$this->db->escape($userData);
$this->user_model->addUser($userData);
}
$data['contentMangement'] = $this->options_model->systemOptions();
$data['pageTitle'] = 'Add User';
$this->load->view('_assets/header', $data);
$this->load->view('addUser', $data);
$this->load->view('_assets/footer');
}
Update:
<?php
$errorMessage = validation_errors('<div class="alert alert-error">', '</div>');
$successMessage = '<div class="alert alert-success"><strong>Thank You</strong> Your User Has Been Added';
if($errorMessage)
{
echo $errorMessage;
}else{
echo $successMessage;
}
?>
I have fixed this issue by the following: