contact(); // since I have not set my default page to contact() } // ------------------------------------------------------------------------ /** * Contact * * Load the 'contact us' page * * @access public */ public function contact() { // define function global $email_sent = false; // load the Zebra library for the Zebra_Form framework $this->load->library('zebra'); # libraries/Zebra.php // create the contact from the helper class // gets the $form object that was returned from the helper $contact_form = $this->zebra->create_form('contact_form'); // if the form was submitted if($contact_form->validate()) { // and the form was valid log_message('info', 'Contact form validated, sending results'); // load the email library from CodeIgniter $this->load->library('email'); // define mail parameters $this->email->from('sender@mail.com', 'Sender'); # from: Sender $this->email->to('recipient@mail.com'); # to: Customer Service Email $this->email->subject('Contact Form); # subj: Contact Form $this->email->message( # message " Email delivered by Contact Form. \n\n From: ".$this->input->post('contact_name')." \n\n Email: ".$this->input->post('contact_email')." \n\n IP: ".$this->input->post('ip')." \n\n Message: \n\n ".$this->input->post('message') ); // if if( $this->email->send() ) { // form submission sent log_message('info', 'Contact form submission was emailed to josh@suggspot.com'); // let's remember the email was sent so we can tell the view $email_sent = true; } else { // could not send form submission log_message('info', 'Failed to send the form submission'); // report the error to the user $this->error['mail_form'] = 'We failed to receive your inquiry! Please try again later.'; $email_sent = false; // unnecessary but good visual } // print email debugger to the logs, which I think is pretty useful. log_message('debug', $this->email->print_debugger()); } // define data we want in our view $data = array( # view data 'page_title' => 'Contact', # 'contact_form' => $contact_form, # pass contact form to view 'error' => $this->error, # errors that may have been recorded 'email_sent' => $email_sent, # tell view if email was sent or not ); // show the view to the user $this->load->view('contact', $data); # views/contact.php } } ?>