CodeIgniter Forums
Login Validation - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: Login Validation (/showthread.php?tid=1957)



Login Validation - El Forum - 07-07-2007

[eluser]Unknown[/eluser]
Is there a cleaner way to use the Validation class to check two fields to see if they are valid together?

At the moment I do something like the following:
Code:
$rules['username'] = 'trim|required';
$rules['password'] = 'trim|required|callback__check_combo|sha1';

function _check_combo($val)
{
  // There are some DB calls usually but for the sake of
  // simplicity im just going to type it out
  if ($this->input->post('username') == 'bob' && sha1($val) == 'cow')
    return TRUE;

  return FALSE;
}

I was wondering if there was a cleaner way to do this? Because atm I'm trusting the the username validation will be done first. And other than that, if there is a problem with username, it will still call the _check_combo function (as it should), but I don't want it to work this way.

Thank you


Login Validation - El Forum - 07-11-2007

[eluser]Grahack[/eluser]
try to see if [url="http://ellislab.com/forums/viewthread/55818/"]this discussion[/url] is of any help