/** * 添加用户 */ function addUser() { $role_list = $this->user->roleList('state=1'); if ($_SERVER['REQUEST_METHOD'] == 'POST') { if ($this->user->userExist($_POST['username'])) { $this->error('用户名已经存在!'); } if (!empty($_POST['email']) && $this->user->emailExist($_POST['email'])) { $this->error('Email已经存在!'); } $auth_class = new auth(); C('AUTH_EMAIL_ACTIVATE', FALSE); //关闭电子邮件激活 if ($auth_class->register($_POST)) { $this->success('添加成功'); } } $this->assign('role_list', $role_list); $this->display(); }
<?php require_once './../persistence.class.php'; require_once './../auth.class.php'; $uid = "eddadmin"; $pass = "******"; $userData = ['FirstName' => 'dont', 'LastName' => 'fail', 'Username' => 'this', 'Email' => 'unit', 'Gender' => 'test']; $auth = new auth($uid); $user = $auth->register($uid, $pass, $userData); $status = $user->authenticated() ? "Sucess" : $user->fail_reason(); echo $status;
<?php require dirname(__FILE__) . '/../dbConnection.php'; require dirname(__FILE__) . '/../lib/auth.class.php'; $auth = new auth(); $username = $_POST["email"]; $email = $username; $password = $_POST["password"]; $reEntryPassword = $password; $currency = $_POST["currency"]; $auth->register($username, $password, $reEntryPassword, $email, $currency);
<input type="password" name="pass" placeholder="Пароль" required> <input type="submit" name="login" value="Авторизироваться!"> </form> <a href="?action=register">Register</a> '; } if (isset($_GET['action']) and $_GET['action'] == 'logout') { //logouting $user->logout(); } if (isset($_POST['login'])) { //logging if ($user->login($_POST['nick'], $_POST['pass'])) { } else { echo $user->error_msg; } } if (isset($_POST['register'])) { //registering if ($user->register($_POST['nick'], $_POST['email'], $_POST['pass'], $_POST['r_pass'], $_POST['name'])) { } else { echo $user->error_msg; } } if (isset($_POST['check'])) { //validating if (!$user->verify($_POST['code'])) { echo $user->error_msg; } } include 'footer.php';