Skip to content

Instantly share code, notes, and snippets.

@alex-zige
Created July 29, 2011 04:43
Show Gist options
  • Save alex-zige/1113145 to your computer and use it in GitHub Desktop.
Save alex-zige/1113145 to your computer and use it in GitHub Desktop.
Customized Login control
public function signup($data,$form){
Debug::show($data);
//get the Rego and Password
$rego=$data['RegoNo'];
$pwd=$data['Password'];
$flag=$this->validuser($rego,$pwd);
Debug::show($flag);
if ($flag !=true)
{
$msg="password wrong or wrong username";
//Warning:: password wrong or wrong username
return $this->renderWith(array('Error','Page'));
}else{
// true
//Save Into Session Object
Session::set('Login', true);
Director::redirect('/iwi-register');
}
}
public function validuser($rego,$password)
{
Debug::show($password);
//do database query
$selecte_user = DataObject::get_one('User',"RegNo = '".$rego."'",'','','');
Debug::show($selecte_user);
if (isset($selecte_user))
{
//testing password
$pwdInsystem=$selecte_user->Password;
Debug::show($pwdInsystem);
return ($pwdInsystem == $password) ? true : false ;
}else {
return false;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment