title: pass parameter from url to cakephp
body: <p>I need to send parameter from URL to cakephp controller. I have message table with two parameter 'ufrom' and 'uto'. in controller i want to save this values in message table.</p>
  
  <p>I put in the URL:</p>
  
  <pre><code>http://localhost/ar/messages/add?ufrom=9&amp;uto=3
  </code></pre>
  
  <p>in MessagesController i have function:</p>
  
  <pre><code>public function add() {
  
  if(($this-&gt;request-&gt;query['uto'])and($this-&gt;request-&gt;query['ufrom'])){
          $this-&gt;Message-&gt;create();
          if ($this-&gt;Message-&gt;save($this-&gt;request-&gt;data)) {
              $this-&gt;set('addMessage',TRUE);
              $this-&gt;set('ufrom',$this-&gt;request-&gt;query['ufrom']);
              $this-&gt;set('uto',$this-&gt;request-&gt;query['uto']);
              $this-&gt;redirect(array('action' =&gt; 'index'));
          } else {
              $this-&gt;Session-&gt;setFlash(__('The message could not be saved. Please, try again.'));
          }
  
          $targets = $this-&gt;Message-&gt;Target-&gt;find('list');
          $this-&gt;set(compact('targets'));
  }
  else{
      $this-&gt;set('error',true);
  }
  </code></pre>
  
  <p>}</p>
  
  <p>and in add.ctp i have:</p>
  
  <pre><code>&lt;?php
  if(isset($error)){
    echo('error');
  }
  else{
    echo json_encode($ufrom);
    echo json_encode($uto);
    echo json_encode($addMessage);
  }
  ?&gt;
  </code></pre>
  
  <p>but when i use the above URL i see:</p>
  
  <pre><code>Notice (8): Undefined variable: ufrom [APP\View\Messages\add.ctp, line 6]null
  Notice (8): Undefined variable: uto [APP\View\Messages\add.ctp, line 7]null
  Notice (8): Undefined variable: addMessage [APP\View\Messages\add.ctp, line 8]null
  </code></pre>
  
  <p>and Nothing is stored in the database. I'm new in cakephp. please help.</p>