title: CakePHP Contact Form
body: <p>I have built a contact form using CakePHP on my site. The controller logic is as follows:</p>
  
  <pre><code>&lt;?php
  
  class ContactController extends AppController
  {
      var $helpers = array ('Html','Form');
  
      var $components = array ('Email','RequestHandler');
  
      var $name = 'Contact';
  
      function beforeFilter()
      {
          parent::beforeFilter();
  
          $this-&gt;Auth-&gt;allow(array('*'));  
      }
  
      function index()
      {
          if ($this-&gt;RequestHandler-&gt;isPost())
          {
              $this-&gt;Contact-&gt;set($this-&gt;data);
              if ($this-&gt;Contact-&gt;validates())
              {
                  $this-&gt;Email-&gt;to = '###';  
                  $this-&gt;Email-&gt;subject = 'Contact message from ' . $this-&gt;data['Contact']['name'];  
                  $this-&gt;Email-&gt;from = $this-&gt;data['Contact']['email'];  
  
                  $this-&gt;Email-&gt;send($this-&gt;data['Contact']['message']);
  
                  $this-&gt;render('success');
              }
          }
      }
  
  }
  
  ?&gt;
  </code></pre>
  
  <p>What I want to do is when a user submits the form is show another view file such as <code>success.ctp</code> but what happens is even though they have a new view they could refresh the page and send the data again and again. How do I stop this...</p>
  
  <p>Can anyone help? Thanks</p>