Controller.php
public function contact()
{
if($this->Session->check('Message.message_send_success')) {
$this->Session->delete('Message.message_send_success');
}
if ($this->request->is('post')) {
$author = $this->viewVars['get_author'];
if (!$author) {
return $this->Session->setFlash(
'Both fields are required!',
'default',
array('class' => 'redTxt'),
'message_send_error');
} else {
$sender_name = ucfirst($author[0]['User']['username']);
$email = $author[0]['User']['email'];
$user_id = $author[0]['User']['id'];
$this->loadModel('User');
$title = $this->request->data['User']['title'];
$body = $this->request->data['User']['body'];
if (!$title && !$body) {
return $this->Session->setFlash(
'Both fields are required!',
'default',
array('class' => 'redTxt'),
'message_send_error');
}
$Email = new CakeEmail();
$Email->from(
array($email => $title))
->to($email)
->subject($title)
->emailFormat('html')
->send('From '.h($sender_name).' '.h($body));
$this->Session->setFlash(
'The message has been send!',
'default',
array('class' => 'alert alert-success'),
'message_send_success');
}
}
$this->set('title', 'Contact Us');
}
}view.phpSession->check('Message.message_send_success')): ?> THANK FOR YOUR CONTACT US!
your message has been send to us successfully.Go back to home

0 comments:
Post a Comment