/** * 用户注册 * @Post("/register") */ public function registerAction() { $this->_validation->add('vcode', new PresenceOf(array('message' => '验证码错误!', 'cancelFail' => true)))->add('mobile', new Mobile(array('message' => '请输入正确的手机号', 'cancelOnFail' => true)))->add('mobile', new Uniqueness(array('message' => '手机号已经存在!', 'model' => 'Users', 'cancelOnFail' => true)))->add('password', new StringLength(array('max' => 20, 'min' => 6, 'messageMinimum' => '密码长度最少6位(包括6位)', 'messageMaximum' => '密码长度不能大于20位(包括20位)', 'cancelOnFail' => true)))->add('sex', new InclusionIn(array('message' => '性别选择错误', 'domain' => array('1', '2')))); $params = $this->validate(); $mobile = $params['mobile']; $vcode = $params['vcode']; $keyName = self::REGISTER_VCODE . $mobile; if (!$this->checkVcode($keyName, $vcode)) { throw new Exception('验证码错误', Messages::$ERROR_FORMAT); } $user = new Users(); $messages = $user->register($params); if (count($messages)) { throw new Exception($messages[0], Messages::$ERROR_FORMAT); } }
/** * 注册用户 */ public function registerAction() { $param = $this->request->getPost(); $user_name = empty($param['user_name']) ? '' : $param['user_name']; $user_pwd = empty($param['user_pwd']) ? '' : $param['user_name']; $user_headimg = empty($param['user_headimg']) ? '' : $param['user_headimg']; $user_email = empty($param['user_email']) ? '' : $param['user_email']; $user_sex = empty($param['user_sex']) ? '' : $param['user_sex']; $userModel = new Users(); $result = $userModel->register($user_name, $user_pwd, $user_headimg, $user_email, $user_sex); if ($result) { $ajaxCode = array('code' => '0', 'message' => 'successful'); } else { $ajaxCode = array('code' => '1', 'message' => 'fail'); } echo json_encode($ajaxCode); }
/** * Registers a user in the system */ function Users_register_post() { $provider = null; $icon = null; $username = null; $activation = null; extract($_REQUEST, EXTR_IF_EXISTS); if (Q_Config::get('Users', 'login', 'noRegister', false)) { throw new Q_Exception("Cannot directly register a user.", array('identifier', 'emailAddress', 'mobileNumber')); } if (empty($username)) { throw new Q_Exception("Please enter a username", 'username'); } $user = Users::register($username, Users::requestedIdentifier(), $icon, $provider, compact('activation')); Users::setLoggedInUser($user); // this also logs the user in Users::$cache['user'] = $user; }
/** Register for an account * @access public * @return void */ public function registerAction() { if ($this->_auth->hasIdentity()) { $this->getFlash()->addMessage('You are already logged in and registered.'); $this->_redirect('/users/account'); } else { $salt = $this->_helper->config()->auth->salt; $form = new RegisterForm(); $this->view->form = $form; if ($this->getRequest()->isPost() && $form->isValid($this->_request->getPost())) { $to = array(array('email' => $form->getValue('email'), 'name' => $form->getValue('first_name') . ' ' . $form->getValue('last_name'))); $emailData = array('email' => $form->getValue('email'), 'name' => $form->getValue('first_name') . ' ' . $form->getValue('last_name'), 'activationKey' => md5($form->getValue('username') . $form->getValue('first_name'))); $this->_users->register($form->getValues()); $this->_helper->mailer($emailData, 'activateAccount', $to); $this->getFlash()->addMessage('Your account has been created. Please check your email.'); $this->redirect('/users/account/activate/'); $form->populate($form->getValues()); $this->getFlash()->addMessage('There are a few problems with your registration<br/> Please review and correct them.'); } } }
<?php include_once 'class/user.php'; $obj = new Users(); $obj->table = 'users'; $obj->connect(); if ($_POST) { if (isset($_POST['register'])) { echo $obj->register($_POST); } } echo $obj->display_register();
<?php include_once "config.php"; $json = file_get_contents('php://input'); $obj = json_decode($json); if ($obj[0]->username == "") { $response = array('status' => 0, 'description' => "Mendatory values not pprovided"); } else { $usr = new Users($obj); $usr->storeFormValues($obj); $res = $usr->register($obj); if ($res == 1) { $response = array('status' => 1, 'description' => "Successful"); } else { if ($res == -1) { $response = array('status' => 0, 'description' => "Email already registered"); } else { if ($res == -2) { $response = array('status' => 0, 'description' => "Mobile Number already registered"); } } } echo json_encode($response); }
<?php include_once 'functions.php'; $user = new Users(); if ($user->session()) { header('Location: homepage.php'); } if ($_SERVER["REQUEST_METHOD"] == "POST") { $reg = $user->register($_POST['username'], $_POST['password'], $_POST['email']); if ($reg) { echo 'You have successfully registered <a href="login.php">Login here</a>'; } else { echo 'Username or email is already taken, try again'; } } ?> <html> <form method="POST" action="register.php" name="register"> Username: <input type="text" name="username"/><br> Password: <input type="password" name="password"/><br> E-mail: <input type="text" name="email"/><br> <input type="submit" value="Register"/> </form> </html>
<body class="hold-transition skin-black sidebar-mini"> <?php //print_r($_SESSION); if (!empty($_REQUEST['register'])) { $db = Database::obtain(DB_SERVER, DB_USER, DB_PASS, DB_DATABASE); $db->connect(); $password = $_REQUEST['password']; $email = $_REQUEST['email']; $first = $_REQUEST['first']; $last = $_REQUEST['last']; $u = new Users('unknown', BASE_DOMAIN); $register = $u->register($email, $password, $first, $last); $avatar = $u->my_avatar($my_id); } if (!empty($_REQUEST['email']) && empty($_REQUEST['register'])) { //LOGGING IN //LOGGING IN $db = Database::obtain(DB_SERVER, DB_USER, DB_PASS, DB_DATABASE); $db->connect(); $password = $_REQUEST['password']; $email = $_REQUEST['email']; $u = new Users('unknown', BASE_DOMAIN); $login = $u->login($email, $password); //print_r($login); //$avatar = $u->my_avatar($_SESSION['uid']); //sessions set in users class on login //get user data
/** * Registers a user. Can be hooked to 'Users/register' before event * so it can override standard functionality. * Method ensures user registration based on full name and also handles registration of * invited user * @method register * @static * @param {string} $fullName The full name of the user in the format 'First Last' or 'Last, First' * @param {string} $identifier User identifier * @param {array} $icon=array() User icon * @param {string} $provider=null Provider * @param {array} $options=array() An array of options that could include: * "activation": The key under "Users"/"transactional" config to use for sending an activation message. * @return {Users_User} * @throws {Q_Exception_WrongType} If identifier is not e-mail or modile * @throws {Q_Exception} If user was already verified for someone else * @throws {Users_Exception_AlreadyVerified} If user was already verified * @throws {Users_Exception_UsernameExists} If username exists */ static function register($fullName, $identifier, $icon = array(), $provider = null, $options = array()) { if (is_array($provider)) { $options = $provider; $provider = null; } /** * @event Users/register {before} * @param {string} username * @param {string} identifier * @param {string} icon * @return {Users_User} */ $return = Q::event('Streams/register', compact('name', 'fullName', 'identifier', 'icon', 'provider', 'options'), 'before'); if (isset($return)) { return $return; } // calculate first and last name out of name if (empty($fullName)) { throw new Q_Exception("Please enter your name", 'name'); } $name = self::splitFullName($fullName); if (empty($name['first']) && empty($name['last'])) { // this is unlikely to happen throw new Q_Exception("Please enter your name properly", 'name'); } self::$cache['register'] = $name; if ($provider !== 'invite') { $user = Users::register("", $identifier, $icon, $provider, $options); } else { if (!empty($identifier)) { $rid = Users::requestedIdentifier($type); $user = Users::userFromContactInfo($type, $rid); if (!$user) { throw new Users_Exception_NoSuchUser(); } } else { $user = Users::loggedInUser(); } } /** * @event Users/register {after} * @param {string} username * @param {string} identifier * @param {string} icon * @param {Users_User} 'user' * @return {Users_User} */ Q::event('Streams/register', compact('name', 'identifier', 'icon', 'user', 'provider', 'options'), 'after'); return $user; }
<?php /* |---------------------------------------------- | App Routes |---------------------------------------------- */ /** * Users */ Route::get('user', function () { Users::index(); }); Route::get('user/auth', function () { Users::auth(); }); Route::get('user/logout', function () { Users::Logout(); }); Route::get('user/register', function () { Users::register(); });
<?php // Collecting user info for the fist time // and registering their accounts include 'users.php'; include '../config.php'; if (isset($_POST)) { $username = $_POST['username']; $password = $_POST['password']; $usr = new Users($db); try { $is_correct = $usr->register($username, $password); if ($is_correct) { echo "Details Correct."; } else { echo "Wrong details"; } } catch (PDOException $e) { echo $e->getMessage(); } }
$promoSale = 0; $registerSale = 0; $email = null; if (!empty($_POST['cart_email']) && !$users->is_auth_shopuser() && !empty($_POST['cart_password'])) { $users->setEmail($_POST['cart_email']); $users->setName($_POST['cart_name']); $users->setPhone1($_POST['cart_phone']); $users->setAddress($_POST['cart_address']); if (!empty($_POST['cart_password'])) { $users->setPassword($_POST['cart_password']); } else { $password = new Password(); $users->setPassword($password->generate()); } if (!$users->get_user_by_email($_POST['cart_email'])) { $user = $users->register(); $user_register = true; } else { $smarty->assign('error_register_message', 'Пользователь с тами email уже зарегистрирован'); $error_register = true; } //если ввел пароль, то отпавляем письмо о регистрации пользователя if (!empty($_POST['cart_password']) && $user_register) { $mail_template = $db->get_single("SELECT template FROM fw_mails_templates WHERE mail_key='REGISTOR_MAIL'"); $message_body = $smarty->fetch('/modules/cabinet/front/templates/registration_mail.txt'); $message_body = $mail_template['template']; $message_body = str_replace("{site_url}", BASE_URL, $message_body); $message_body = str_replace("{login}", $user['login'], $message_body); $message_body = str_replace("{password}", $_POST['cart_password'], $message_body); $headers = "Content-type: text/html; charset=windows-1251 \r\n"; $headers .= "From: " . MAIL_FROM . ".ru>\r\n";
/** * Registers a user. Can be hooked to 'Users/register' before event * so it can override standard functionality. * Method ensures user registration based on full name and also handles registration of * invited user * @method register * @static * @param {string} $fullName The full name of the user in the format 'First Last' or 'Last, First' * @param {string|array} $identifier Can be an email address or mobile number. Or it could be an array of $type => $info * @param {string} [$identifier.identifier] an email address or phone number * @param {array} [$identifier.device] an array with keys "deviceId", "platform", "version" * to store in the Users_Device table for sending notifications * @param {array} [$icon=array()] Array of filename => url pairs * @param {string} [$provider=null] Provider such as "facebook" * @param {array} [$options=array()] An array of options that could include: * @param {string} [$options.activation] The key under "Users"/"transactional" config to use for sending an activation message. Set to false to skip sending the activation message for some reason. * @return {Users_User} * @throws {Q_Exception_WrongType} If identifier is not e-mail or modile * @throws {Q_Exception} If user was already verified for someone else * @throws {Users_Exception_AlreadyVerified} If user was already verified * @throws {Users_Exception_UsernameExists} If username exists */ static function register($fullName, $identifier, $icon = array(), $provider = null, $options = array()) { if (is_array($provider)) { $options = $provider; $provider = null; } /** * @event Streams/register {before} * @param {string} username * @param {string|array} identifier * @param {string} icon * @return {Users_User} */ $return = Q::event('Streams/register', compact('name', 'fullName', 'identifier', 'icon', 'provider', 'options'), 'before'); if (isset($return)) { return $return; } // calculate first and last name out of name if (empty($fullName)) { throw new Q_Exception("Please enter your name", 'name'); } $name = self::splitFullName($fullName); if (empty($name['first']) && empty($name['last'])) { // this is unlikely to happen throw new Q_Exception("Please enter your name properly", 'name'); } // this will be used in Streams_after_Users_User_saveExecute Streams::$cache['register'] = $name; $user = Users::register("", $identifier, $icon, $provider, $options); /** * @event Streams/register {after} * @param {string} username * @param {string|array} identifier * @param {string} icon * @param {Users_User} 'user' * @return {Users_User} */ Q::event('Streams/register', compact('name', 'identifier', 'icon', 'user', 'provider', 'options'), 'after'); return $user; }
<?php if (isset($_POST) && !empty($_POST)) { $usr = new Users(); $usr->storeFormValues($_POST); if ($usr->register()) { header('HTTP/1.0 302 Found'); header("Location: index.php?map=login&page=index"); die; } else { echo '<div class="row"> <div class="col-md-6 col-md-offset-3"> <div class="alert alert-danger" role="alert"> <center>Deze gebruikersnaam is al in gebruik!</center> </div> </div></div> '; } } ?> <link rel="stylesheet" href="/comingsoon/assets/bootstrap/css/bootstrap.css"/> <link id="theme" rel="stylesheet" href="/comingsoon/assets/blue.css"/> <div class="container" style="margin-top:-100px;"> <div class="wrapper-bg"> <div class="wrapper"> <div class="shadow"></div> <!-- <div class="header"><img src="./style/images/logo.png" alt="MyGig" /></div>--> <div class="header"> </div> <div class="opacity">
</div> <div class="form-group"> <label for="inputpass">Senha</label> <input type="password" class="form-control" name="password" id="pass" maxlength="8" required/> <label for="repeatpass">Repita a senha</label> <input type="password" class="form-control" name="repeat" id="repeat" maxlength="8" required/> </div> <div class="form-group"> <button type="submit" class="btn btn-default col-xs-12" name="cadastro">Solicitar Cadastro</button> <?php if (!isset($_POST['cadastro'])) { echo $_POST['username']; } else { $usr = new Users(); $usr->storeFormValues($_POST); if ($result = $usr->register()) { ?> <span class="pull-left"><?php echo $result; ?> </span><?php } else { ?> <span class="pull-left"></span><?php } } ?> <a href="index.php" class="pull-right new-account">Voltar</a> </div> </form> </div>
$usr->storeFormValues($_POST); if ($_POST['password'] == $_POST['conpassword']) { //passwords do match// } else { echo 'Passwords do not match. <br> Please Try Again </br> <a href=login.php> Click Here </a>'; exit; } //Check if the username is already taken $username = $_POST['username']; $con = new PDO(DB_DSN, DB_USERNAME, DB_PASSWORD); $sthandler = $con->prepare("SELECT username FROM users WHERE username = :username"); $sthandler->execute(array(':username' => $username)); if ($sthandler->rowCount() > 0) { echo 'Sorry, the username ' . $_POST['username'] . ' is already in use.'; } else { echo $usr->register(); } } } ?>
| **/ Route::get($_route . "/users", function () { return Users::index(); }); Route::get($_route . "/users/list", function () { return Users::list_users(); }); Route::get($_route . "/users/auth", function () { return Users::auth(); }); Route::get($_route . "/users/logout", function () { return Users::Logout(); }); Route::get($_route . "/users/register", function () { return Users::register(); }); Route::get($_route . "/users/lostpass", function () { return Users::lostpass(); }); Route::get($_route . "/users/update", function () { return Users::update_users_data(); }); Route::get($_route . "/users/update/{id}", function ($id) { return Users::update_users($id); }); Route::get($_route . "/users/delete", function () { return Users::delete_users(); }); Route::get($_route . "/users/new", function () { return Users::new_users();
<label for="passwd">Password : </label> <input type="password" id="passwd" maxlength="30" required name="password" /> </li> <li> <label for="conpasswd">Confirm Password : </label> <input type="password" id="conpasswd" maxlength="30" required name="conpassword" /> </li> <li class="buttons"> <input type="submit" name="register" value="Register" /> <input type="button" name="cancel" value="Cancel" onclick="location.href='index.php'" /> </li> </ul> </form> </div> </div> </body> </html> <?php } else { $usr = new Users(); $usr->storeFormValues($_POST); if ($_POST['password'] == $_POST['conpassword']) { echo $usr->register($_POST); } else { echo "Password and Confirm password not match"; } }