[eluser]Tekamba[/eluser]
Here is the code from my form handling controller. I have a feeling I have something in here that I have not done correctly and that may be causing the issue, this is all held in a class called email. "Main" is the website controller, and "contact" is the webpage where the contact form resides. The email is sent when form validation completes, the only error I have is when the function callcontact() call is made (even if I do it without the separate function I still end up with the error that main/contact.php can't be located.
function callcontact() {
$this->load->view('main/contact');
}
function contact_send() {
/*******************************************/
/* A contact form was submitted */
/*******************************************/
// load the form validation library
$this->load->library('form_validation');
// setup validation rules on form fields
$this->form_validation->set_rules('name', 'Name', 'trim|required');
$this->form_validation->set_rules('phone', 'Phone', 'trim|required');
$this->form_validation->set_rules('email', 'Email Address', 'trim|required|valid_email');
$this->form_validation->set_rules('reason', 'Reason for contact request', 'trim|required|');
// run form validation
if($this->form_validation->run() == FALSE)
{
// form failed to validate so pass the errors to flashdata
// and then return user to form
$this->session->set_flashdata('errors', validation_errors());
$this->callcontact();
} else {
// validator has passed - compile the email
$messagebody = "Name: ";
$messagebody .= $name = $this->input->post('name');
$messagebody .= "<br>Phone: ";
$messagebody .= $email = $this->input->post('phone');
$messagebody .= "<br>E-Mail: ";
$messagebody .= $email = $this->input->post('email');
$messagebody .= "<br>Reason: ";
$messagebody .= $email = $this->input->post('reason');
$msg_subject = 'Contact Form Request';
$msg_valid_send = 'Thank you for your contact request';
$msg_error_send = 'Contact form message did not process properly';
}
/********************************************/
/* Validation&Message; construction are done */
/* send the message to Staff */
/********************************************/
// create array to store smtp values
$config = Array(
'protocol' => $this->config->item('smtp_protocol'),
'smtp_host' => $this->config->item('smtp_host'),
'smtp_port' => $this->config->item('smtp_port'),
'smtp_user' => $this->config->item('smtp_user'),
'smtp_pass' => $this->config->item('smtp_pass'),
'mailtype' => $this->config->item('smtp_mailtype'),
'charset' => $this->config->item('smtp_charset'),
'recipient' => $this->config->item('smtp_recipient'));
// load the email library class
$this->load->library('email', $config);
$this->email->set_newline("\r\n");
// set to, from, message, etc
$this->email->from($this->input->post('email'));
$this->email->to($config['recipient']);
$this->email->subject($msg_subject);
$this->email->message($messagebody);
// attempt to send the email
if ($result = $this->email->send()) {
$message = $msg_valid_send;
} else {
$message = $msg_error_send;
}
$this->session->set_flashdata('messagestatus', $message);
// send user back to the appropriate form
$this->callcontact();
//$this->load->view('send_contact');
}