Posted By

antoniomax on 11/21/08


Tagged

sendmail ci


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

localhorst
vali29


CI sendmail


 / Published in: PHP
 

URL: http://codeigniter.com/forums/viewthread/79766/

malformed but all set

  1. class Contact extends Controller {
  2.  
  3. function index() {
  4.  
  5. // Validations
  6. $this->load->library('validation');
  7. $rules['name'] = "required";
  8. $rules['email'] = "required|valid_email";
  9. $this->validation->set_rules($rules);
  10.  
  11. // Input and textarea field attributes
  12. $data['name'] = array('name' => 'name', 'id' => 'name');
  13. $data['email'] = array('name' => 'email', 'id' => 'email');
  14. $data['comments'] = array('name' => 'comments', 'id' => 'comments', 'rows' => 3, 'cols' => 40);
  15.  
  16. // Checkbox attributes
  17. $data['graphic'] = array('name' => 'services[]', 'id' => 'graphic', 'value' => 'Graphic Design', 'checked' => FALSE);
  18. $data['web'] = array('name' => 'services[]', 'id' => 'web','value' => 'Web Design/Development', 'checked' => FALSE);
  19. $data['myspace'] = array('name' => 'services[]', 'id' => 'myspace','value' => 'Myspace Design', 'checked' => FALSE);
  20. $data['cms'] = array('name' => 'services[]', 'id' => 'cms','value' => 'CMS', 'checked' => FALSE);
  21.  
  22. if ($this->validation->run() == FALSE) {
  23.  
  24. $this->load->view('contact/contact_view', $data);
  25.  
  26. } else {
  27.  
  28. // Get POST data
  29. $name = $this->input->post('name');
  30. $email = $this->input->post('email');
  31. $comments = $this->input->post('comments');
  32. $services = "";
  33.  
  34. foreach($this->input->post('services') as $value) {
  35.  
  36. $services .= "$value\n";
  37.  
  38. }
  39.  
  40. $message = $name . " would like the following services:\n\n" . $services . "\n\n". $name ." also said:\n" . $comments;
  41.  
  42. // Set our email fields
  43. $this->email->from($email, $name);
  44. $this->email->to('[email protected]');
  45. $this->email->subject('Your services are requested!');
  46. $this->email->message($message);
  47. $this->email->send();
  48.  
  49. //load our view file
  50. $this->load->view('contact/contact_success');
  51.  
  52. }
  53.  
  54. }
  55.  
  56. }

Report this snippet  

You need to login to post a comment.