Guest User

Untitled

a guest
Jul 19th, 2018
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. <?php
  2.  
  3. class ContactsController extends AppController {
  4.  
  5. var $name = 'Contacts';
  6. var $uses = array('Client');
  7.  
  8. public $helpers = array('Form', 'Html');
  9. public $components = array('Email');
  10.  
  11. public function index(){
  12. if( !empty($this->data) ){
  13. $mensagem = @$this->Email->render($this, 'faleconosco', $this->data);
  14. if( @$this->Email->send("junio@lapisraro.com.br", "Formulário de contato - Araujo Foto", $mensagem ) ){
  15.  
  16. if((int) $this->data['Contact']['wants_receive_email']) {
  17.  
  18. $this->Client->create();
  19. $client = array();
  20. $client['Client']['name'] = $this->data['Contact']['name'];
  21. $client['Client']['email'] = $this->data['Contact']['email'];
  22. $client['Client']['remote_addr'] = env('REMOTE_ADDR');
  23. $client['Client']['agree_terms'] = 1;
  24.  
  25. @$this->Client->save($client);
  26. }
  27.  
  28. $this->Session->setFlash(__('Contato enviado com sucesso.<br>Obrigado pela participação.', true));
  29. $this->render();
  30.  
  31. } else {
  32. $this->Session->setFlash(__('Houve um problema durante o envio. Tente novamente.', true));
  33. }
  34. }
  35. }
  36.  
  37. }
  38.  
  39. ?>
Add Comment
Please, Sign In to add comment