title: Codeigniter Form Validation Callback checking multiple fields
body: <p>I have this controller set up for a login:</p>
  
  <pre><code>&lt;?php
  class Login extends Controller {
  
      function __construct() {
          parent::Controller();
          $this-&gt;form_validation-&gt;set_error_delimiters('', '');
          $this-&gt;output-&gt;enable_profiler(TRUE);
      }
  
      function index(){
  
          redirect('/login/terminal');
  
      }
  
      function terminal() {
      // terminal login
  
          $this-&gt;form_validation-&gt;set_rules(array('username','password'), 'Username', 'callback_terminal_login_check[$username,$password]');
          if ($this-&gt;form_validation-&gt;run() == FALSE) {
              $this-&gt;load-&gt;view('login_header');
              $this-&gt;load-&gt;view('login_terminal');
              $data['version'] = $this-&gt;master-&gt;GetVersion();
              $this-&gt;load-&gt;view('login_footer', $data);
          } else {
              redirect('/terminal');
          }
  
      }
  
      function terminal_login_check($username,$password) {
      // callback function to perform terminal login  
  
          if ($this-&gt;authentication-&gt;DoTerminalAuthentication($username,$password)) {
              echo $username;
              return TRUE;
          } else {
              $this-&gt;form_validation-&gt;set_message('terminal_login_check', 'Invalid');
              return FALSE;
          }
  
  
      }
  
  }
  </code></pre>
  
  <p>What I am looking at is the line that does the form validation callback >>  <code>$this-&gt;form_validation-&gt;set_rules(array('username','password'), 'Username', 'callback_terminal_login_check[$username,$password]');</code></p>
  
  <p>I know this is not right.  Basically what I want to do is check the username and password against the Authentication->DoTerminalAuthentication model to process the user's login.  I want to pass the <code>$username</code> and <code>$password</code> form fields.  Here is my form view if it helps:</p>
  
  <pre><code>&lt;div id="title"&gt;Terminal Login&lt;/div&gt;
  &lt;?php 
      if (validation_errors()) {
          echo '&lt;div id="error"&gt;' . validation_errors() . '&lt;/div&gt;';
      }
  ?&gt;
  
  &lt;?=form_open('login/terminal');?&gt;
  &lt;?=form_label('Username', 'username')?&gt;&lt;br /&gt;
  &lt;?=form_input(array('id'=&gt;'username','name'=&gt;'username','value'=&gt;set_value('username')))?&gt;&lt;br /&gt;
  &lt;?=form_label('Password', 'password')?&gt;&lt;br /&gt;
  &lt;?=form_password(array('id'=&gt;'password','name'=&gt;'password'))?&gt;&lt;br /&gt;
  &lt;?=form_submit(array('name'=&gt;'passwordsubmit','value'=&gt;'Login &gt;&gt;'))?&gt;&lt;br /&gt;
  &lt;?=form_close();?&gt;
  </code></pre>