02-21-2012, 03:17 AM
[eluser]the_unforgiven[/eluser]
Of course sorry i forgot about that lol
Of course sorry i forgot about that lol
Code:
function send()
{
$this->load->library('form_validation');
// Set Validation Rules
$this->form_validation->set_rules('name', 'Name', 'trim|required|min_length[3]');
$this->form_validation->set_rules('email', 'Email', 'trim|required|valid_email');
$this->form_validation->set_rules('phone', 'Phone', 'trim|required|max_length[12]');
$this->form_validation->set_rules('message', 'Message', 'trim|required|min_length[2]');
// You can set additional rules here, but keep CAPTCHA test
$rules = array(
array(
"field" => "recaptcha_challenge_field",
"label" => "reCAPTCHA",
"rules" => "required|recaptcha_matches"
)
);
$this->form_validation->set_rules($rules);
// Validation runs false rteun back to form and show errors
if ($this->form_validation->run() == FALSE) {
$data['title'] = 'Contact us ';
$data['description'] = '';
$data['keywords'] = '';
$data['main_content'] = 'contact';
$data['error'] = $this->session->set_flashdata('error', 'Sorry there where some errors');
$this->load->view('template', $data);
}
// If everything is filled out with no errors procced with sending the form to email and database
else {
$name = $this->input->post('name');
$email = $this->input->post('email');
$message = "Hey guys, someone has requested left a message" . "\n\r\n";
$message .= "Name:". $this->input->post('name') . "\n";
$message .= "Email:". $this->input->post('email') . "\n";
$message .= "Phone:". $this->input->post('phone') . "\n";
$message .= "Message:". $this->input->post('message');
$this->email->from($email, $name);
$this->email->to('[email protected]');
$this->email->subject('req');
$this->email->message($message);
$this->email->send(); // Send the message function to the persons email address
$this->email->clear(); // Clears the form ready for another submission
$data['title'] = 'Thank you, Message received.';
$data['description'] = '';
$data['keywords'] = '';
$data['main_content'] = 'thanks';
$this->load->view('template', $data);
}
}