Thanks so much but I don’t want to go to a different url . when the form submits, I just want it to stay on the same page and show the same page again. Everyother thing I have tried it just shows the footer or goes to main index page
I can post code . the controller:
<?php
error_reporting(E_ALL);
ini_set('display_errors', '1');
App::uses('CakeEmail', 'Network/Email');
class LeadsController extends AppController {
public $helpers = array('Html', 'Form', 'Session');
public $components = array('Session', 'Flash', 'Email');
public function add() {
if ($this->request->is('post')) {
$email = new CakeEmail('default');
$email->from('[noreply@smsold.com](mailto:noreply@smsold.com)')
->to($this->request->data['Lead']['email'])
->subject('Thank you for your submission')
->emailFormat('html');
$emailContent = '
';
$email->send($emailContent);
if ($this->Lead->save($this->request->data)) {
$this->Session->setFlash('Message Successfully Sent!.');
}
}
$this->render('/Pages/contact');
}
}
the form :
<?php echo $this->Form->create('Lead', array('url' => array('controller' => 'leads', 'action' => 'add'))); ?>
<?php echo $this->Form->input('first_name', array('class' => 'f1')); ?>
<?php echo $this->Form->input('last_name', array('class' => 'f1')); ?>
<?php echo $this->Form->input('email', array('class' => 'f1')); ?>
<?php echo $this->Form->input('phone_number', array('class' => 'f1')); ?>
<?php echo $this->Form->input('message', array('class' => 'f2', 'label' => false, 'placeholder' => 'send us a message'
)); ?>
<?php echo $this->Form->hidden('lead_type_id', array('value' => 1)); ?>
<?php echo $this->Form->hidden('priority', array('value' => 2)); ?>
<?php echo $this->Form->hidden('safe', array('value' => 1)); ?>
<?php echo $this->Form->hidden('spam', array('value' => 0)); ?>
<?php echo $this->Form->submit('Submit', array('class' => 'btn btn-primary btn1')); ?>
<?php echo $this->Session->flash(); ?>
<?php echo $this->Form->end(); ?>
THANKS SO MUCH A MILLION THANKS