Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class ContactListing_Controller extends Page_Controller {
- function ContactListingForm() {
- $emailTo = $_GET['email'];
- echo "my EMAIL =". $emailTo;
- return new Form($this, "ContactListingForm", new FieldSet(
- new TextField("Name"),
- new TextField("Phone"),
- new TextField("Email", "Email"),
- new TextareaField("Comment"),
- new HiddenField("MyEmail", "MyEmail", "$emailTo")
- ), new FieldSet(
- new FormAction("ContactListingAction", "Submit")
- ), new RequiredFields());
- }
- public function ContactListingAction($data, $form) {
- $from = 'email@example.co.nz';
- $to = $data['MyEmail'];
- $subject = 'testing for website v11';
- $body = 'This is the body of my email';
- $email = new Email();
- $email->setTemplate('ContactListing_Email');
- $email->setFrom($from);
- $email->setTo($to);
- $email->setSubject($subject);
- $email->populateTemplate($data);
- $email->send();
- Director::redirect(Director::baseURL(). $this->URLSegment . "/?success=1");
- }
- public function Success()
- {
- return isset($_REQUEST['Success']) && $_REQUEST['Success'] == "1";
- }
- }
Add Comment
Please, Sign In to add comment