title: CodeIgniter: Passing variables via URL - alternatives to using GET
body: <p>I'm new to CodeIgniter and have just discovered the difficulties using the GET method of passing variables via the URL  (e.g. domain.com/page.php?var1=1&amp;var2=2).</p>
  
  <p>I gather that one approach is to pass the variables in the URI segments but haven't quite figured out how to do that yet as it seems to create the expectation of having a function in the controller named as the specific URI segment????</p>
  
  <p>Anyway Instead of using GET I've decided to use POST by adapting a submit button (disguised as a link) with the variables in hidden input fields.  I've created the following solution which seems to work fine, but am wondering whether I'm on the right track here or whether there is an easier way of passing variables via a link within CodeIgniter?</p>
  
  <p>I've created the following class in application/libraries/</p>
  
  <pre><code>&lt;?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
  
  class C_variables {
  
  function variables_via_link($action, $link_text, $style, $link_data) {
      $attributes = array('style' =&gt; 'margin:0; padding:0; display: inline;');
      echo form_open($action, $attributes);
      $attributes = array('class' =&gt; $style, 'name' =&gt; 'link');
      echo form_submit($attributes, $link_text);
      foreach ($link_data as $key =&gt; $value){
          echo form_hidden($key, $value);
      }
      echo form_close();
   }
  }
  ?&gt;
  </code></pre>
  
  <p>With the following CSS:</p>
  
  <pre><code>/* 
  SUBMIT BUTTON AS LINK
  adapted from thread: http://forums.digitalpoint.com/showthread.php?t=403667
  Cross browser support (apparently).
  */
  .submit_as_link {
  background: transparent;
  border-top: 0;
  border-right: 0;
  border-bottom: 1px solid #00F;
  border-left: 0;
  color: #00F;
  display: inline;
  margin: 0;
  padding: 0;
      cursor: hand /* Added to show hand when hovering */
  }
  
  *:first-child+html .submit_as_link {  /* hack needed for IE 7 */
  border-bottom: 0;
  text-decoration: underline;
  }
  
  * html .submit_as_link {    /* hack needed for IE 5/6 */
  border-bottom: 0;
  text-decoration: underline;
  }
  </code></pre>
  
  <p>Link then created using the following code in the VIEW:</p>
  
  <pre><code>&lt;?php
  $link = new C_variables;
  $link_data=array('var1' =&gt; 1, 'var2' =&gt; 2);
  $link -&gt;variables_via_link('destination_page', 'here is a link!', 
  'submit_as_link', $link_data);
  ?&gt;
  </code></pre>
  
  <p>Thanks for your help...</p>