Guest User

Untitled

a guest
Jul 15th, 2018
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. class ContactListing_Controller extends Page_Controller {
  2.  
  3.  
  4. function ContactListingForm() {
  5.  
  6.  
  7. $emailTo = $_GET['email'];
  8. echo "my EMAIL =". $emailTo;
  9.  
  10. return new Form($this, "ContactListingForm", new FieldSet(
  11.  
  12. new TextField("Name"),
  13. new TextField("Phone"),
  14. new TextField("Email", "Email"),
  15. new TextareaField("Comment"),
  16. new HiddenField("MyEmail", "MyEmail", "$emailTo")
  17.  
  18.  
  19. ), new FieldSet(
  20.  
  21. new FormAction("ContactListingAction", "Submit")
  22.  
  23. ), new RequiredFields());
  24. }
  25.  
  26. public function ContactListingAction($data, $form) {
  27.  
  28.  
  29.  
  30. $from = 'email@example.co.nz';
  31. $to = $data['MyEmail'];
  32. $subject = 'testing for website v11';
  33. $body = 'This is the body of my email';
  34.  
  35.  
  36. $email = new Email();
  37. $email->setTemplate('ContactListing_Email');
  38. $email->setFrom($from);
  39. $email->setTo($to);
  40. $email->setSubject($subject);
  41.  
  42. $email->populateTemplate($data);
  43.  
  44. $email->send();
  45.  
  46. Director::redirect(Director::baseURL(). $this->URLSegment . "/?success=1");
  47.  
  48. }
  49.  
  50. public function Success()
  51. {
  52. return isset($_REQUEST['Success']) && $_REQUEST['Success'] == "1";
  53. }
  54.  
  55.  
  56. }
Add Comment
Please, Sign In to add comment