本文整理匯總了PHP中UserList::createUser方法的典型用法代碼示例。如果您正苦於以下問題:PHP UserList::createUser方法的具體用法?PHP UserList::createUser怎麽用?PHP UserList::createUser使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類UserList
的用法示例。
在下文中一共展示了UserList::createUser方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: createuser
public function createuser()
{
$errmsg = array();
if ($this->registry->auth->check()) {
header("Location: /store");
return;
}
if (false == preg_match('/^[a-zA-Z0-9_]+$/', $this->registry->request->login)) {
$errmsg[] = 'Login should consist from alphanumeric characters';
}
if (false == preg_match('/^[a-zA-Z0-9_]+$/', $this->registry->request->pass)) {
$errmsg[] = 'Password should consist from alphanumeric characters';
}
if ($this->registry->request->pass !== $this->registry->request->pass_confirm) {
$errmsg[] = 'Wrong password confirmation';
}
/** Instance of UserList class, lib/userlist.class.php */
$ul = new UserList();
/** Check if user exists */
if ($ul->isRegistered($this->registry->request->login)) {
$errmsg[] = 'This username is unavailable.';
}
/** Create new user */
if (false == $ul->createUser($this->registry->request->login, $this->registry->request->pass)) {
$errmsg[] = 'Fatal error. Try again later.';
}
if (count($errmsg) > 0) {
$this->registry->view->errormessages = $errmsg;
$this->registry->view->render('register');
return;
}
unset($ul);
$this->registry->view->render('register_ok');
}