Welcome Guest, Not a member yet? Register   Sign In
The Auth Library 1.0.3 - The Easiest Auth Library for CodeIgniter
#54

[eluser]Bionicmaster[/eluser]
ok, sorry for this parameter, but I modified for call to different forms and paste another code, but here is the right code, and a explanation:

<code>
class Application extends Controller
{

public function username_check($str)
{
return $this->auth->username_check($str);
}

public function reg_username_check($str)
{
return $this->auth->reg_username_check($str);
}

public function reg_email_check($str)
{
return $this->auth->reg_email_check($str);
}
}
</code>

<code>
class Auth
{
function username_check($str)
{
$auth_type = $this->_auth_type($str);
$query = $this->CI->db->query("SELECT * FROM `users` WHERE `$auth_type` = '$str'");

if($query->num_rows === 1)
{
return TRUE;
}
else
{
$this->CI->form_validation->set_message('username_check', $this->CI->lang->line('username_callback_error'));
return FALSE;
}
} // function username_check()

function reg_username_check($str)
{
$query = $this->CI->db->query("SELECT * FROM `users` WHERE `username` = '$str'");

if($query->num_rows <> 0)
{
$this->CI->form_validation->set_message('reg_username_check', $this->CI->lang->line('reg_username_callback_error'));
return FALSE;
}
else
{
return TRUE;
}
} // function reg_username_check()

function reg_email_check($str)
{
$query = $this->CI->db->query("SELECT * FROM `users` WHERE `email` = '$str'");

if($query->num_rows <> 1)
{
return TRUE;
}
else
{
$this->CI->form_validation->set_message('reg_email_check', $this->CI->lang->line('reg_email_callback_error'));
return FALSE;
}
} // function reg_email_check()
}
</code>

and this works all right, because we are loading our CI instance and applies to all Libraries and Controllers, and we avoid using or creating an MY_Controller if we don't use it or need it (or as in my case, is modified before by me)


Messages In This Thread
The Auth Library 1.0.3 - The Easiest Auth Library for CodeIgniter - by El Forum - 03-25-2009, 04:35 PM



Theme © iAndrew 2016 - Forum software by © MyBB