/ Published in: PHP
URL: http://codeigniter.com/forums/viewthread/79766/
malformed but all set
Expand |
Embed | Plain Text
class Contact extends Controller { function index() { // Validations $this->load->library('validation'); $rules['name'] = "required"; $rules['email'] = "required|valid_email"; $this->validation->set_rules($rules); // Input and textarea field attributes // Checkbox attributes $data['graphic'] = array('name' => 'services[]', 'id' => 'graphic', 'value' => 'Graphic Design', 'checked' => FALSE); $data['web'] = array('name' => 'services[]', 'id' => 'web','value' => 'Web Design/Development', 'checked' => FALSE); $data['myspace'] = array('name' => 'services[]', 'id' => 'myspace','value' => 'Myspace Design', 'checked' => FALSE); if ($this->validation->run() == FALSE) { $this->load->view('contact/contact_view', $data); } else { // Get POST data $name = $this->input->post('name'); $email = $this->input->post('email'); $comments = $this->input->post('comments'); $services = ""; foreach($this->input->post('services') as $value) { $services .= "$value\n"; } $message = $name . " would like the following services:\n\n" . $services . "\n\n". $name ." also said:\n" . $comments; // Set our email fields $this->email->from($email, $name); $this->email->subject('Your services are requested!'); $this->email->message($message); $this->email->send(); //load our view file $this->load->view('contact/contact_success'); } } }
You need to login to post a comment.
