• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
auto fill a field from input box

#12
[eluser]the_unforgiven[/eluser]
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);

  }
}


Messages In This Thread
auto fill a field from input box - by El Forum - 02-20-2012, 01:24 PM
auto fill a field from input box - by El Forum - 02-20-2012, 01:55 PM
auto fill a field from input box - by El Forum - 02-20-2012, 02:00 PM
auto fill a field from input box - by El Forum - 02-20-2012, 02:10 PM
auto fill a field from input box - by El Forum - 02-20-2012, 02:21 PM
auto fill a field from input box - by El Forum - 02-20-2012, 02:27 PM
auto fill a field from input box - by El Forum - 02-20-2012, 02:30 PM
auto fill a field from input box - by El Forum - 02-20-2012, 02:48 PM
auto fill a field from input box - by El Forum - 02-20-2012, 02:50 PM
auto fill a field from input box - by El Forum - 02-20-2012, 03:03 PM
auto fill a field from input box - by El Forum - 02-20-2012, 03:18 PM
auto fill a field from input box - by El Forum - 02-21-2012, 03:17 AM
auto fill a field from input box - by El Forum - 02-21-2012, 11:46 AM
auto fill a field from input box - by El Forum - 02-21-2012, 12:27 PM
auto fill a field from input box - by El Forum - 02-21-2012, 12:58 PM
auto fill a field from input box - by El Forum - 02-21-2012, 01:02 PM
auto fill a field from input box - by El Forum - 02-21-2012, 01:20 PM
auto fill a field from input box - by El Forum - 02-21-2012, 01:35 PM
auto fill a field from input box - by El Forum - 02-21-2012, 01:46 PM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.