本文整理汇总了PHP中User::createUser方法的典型用法代码示例。如果您正苦于以下问题:PHP User::createUser方法的具体用法?PHP User::createUser怎么用?PHP User::createUser使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类User
的用法示例。
在下文中一共展示了User::createUser方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionRegister
public function actionRegister()
{
$model = new User('register');
$provinces = Province::model()->findAll();
$provinces = CHtml::listData($provinces, 'idProvince', 'name');
$cities = array();
$districts = array();
if (isset($_POST['User'])) {
$model->attributes = $_POST['User'];
if ($model->createUser()) {
//Log in the new user
$modelLoginForm = new LoginForm();
$modelLoginForm->username = $model->username;
$modelLoginForm->password = $model->conf_password;
//because password has been md5
if ($modelLoginForm->login()) {
$this->redirect(Yii::app()->user->returnUrl);
}
}
if (isset($model->idProvince)) {
$cities = City::model()->findAllByAttributes(array('idProvince' => $model->idProvince));
$cities = CHtml::listData($cities, 'idCity', 'name');
}
if (isset($model->idCity)) {
$districts = District::model()->findAllByAttributes(array('idCity' => $model->idCity));
$districts = CHtml::listData($districts, 'idDistrict', 'name');
}
}
$this->render('register', array('model' => $model, 'provinces' => $provinces, 'cities' => $cities, 'districts' => $districts));
}
示例2: run
public function run()
{
try {
foreach ($this->groups as $g) {
User::createGroup($g);
}
// Add super user
$super = ['email' => 'superadmin@email.com', 'password' => 'password', 'first_name' => 'Fordyce', 'last_name' => 'Gozali', 'slug' => 'fordyce-gozali', 'activated' => true];
$group = User::findGroupByName('Super User');
if ($group) {
$user = User::createUser($super);
$user->addGroup($group);
}
//Add admins
$admins = [['email' => 'admin@email.com', 'password' => 'password', 'first_name' => 'Admin', 'last_name' => '', 'slug' => 'admin', 'activated' => true]];
$group = User::findGroupByName('Admin');
if ($group) {
foreach ($admins as $a) {
$user = User::createUser($a);
$user->addGroup($group);
}
}
} catch (\Exception $e) {
return $this->command->info($e->getMessage());
}
}
示例3: acceptRequest
public static function acceptRequest($req_id, $admin = false)
{
DB::updateRequestAccepted($req_id);
$req = self::getRequest($req_id);
$pass = User::createUser(array('email' => $req['email'], 'login' => $req['login'], 'admin' => $admin ? 1 : 0, 'request_id' => $req_id));
sendMessage($req['email'], "Ваша заявка одобрена. Пароль: {$pass}");
}
示例4: register
public function register()
{
$this->db->begin();
$modelUser = new User();
$res = $modelUser->createUser($this->request->getPost());
if (false == $res) {
$this->db->rollback();
return parent::resWithErrMsg($modelUser->getMessages());
}
$this->db->commit();
return parent::success();
}
示例5: setUser
/**
* Public: Set user
*/
public function setUser($username)
{
$app = App::getInstance();
try {
parent::__construct($username);
} catch (\FelixOnline\Exceptions\ModelNotFoundException $e) {
User::createUser($username);
parent::__construct($username);
}
$this->setVisits($this->getVisits() + 1);
$this->setIp($app['env']['REMOTE_ADDR']);
$this->setTimestamp(time());
$this->save();
}
示例6: post_index
function post_index($f3)
{
$user = \User::createUser(\kksd\Sesi::$DB);
$user->load(array("email=?", $f3->POST['email']));
if ($user->checkLogin($f3->get('POST.email'), $f3->get('POST.password'))) {
$user->load(array("email=?", $f3->POST['email']));
$f3->SESSION['user_type'] = 'admin';
if (!$f3->POST['remember']) {
$f3->SESSION['user'] = $user->id;
$f3->SESSION['user_obj'] = $user;
} else {
$f3->set('COOKIE.user', $user->id, time() + 24 * 3600 * 7);
}
$f3->reroute('@admin_home');
return;
}
\Flash::instance()->addMessage('Wrong password, you morron!', 'danger');
$this->index($f3);
return;
}
示例7: testUser
static function testUser()
{
$user = new User();
$logout = User::logout();
$_POST["user"] = self::generateRandomString();
$_POST["pass"] = self::generateRandomString();
$_POST["email"] = self::generateRandomString();
if ($register = User::createUser()) {
echo 'CREATE USER: <font color="green">Stworzono uzytkownika o id: ' . $register . ' Dane: ' . $_POST["user"] . ' Haslo: ' . $_POST["pass"] . '</font></br>';
} else {
echo 'CREATE USER: <font color="red">ERROR!</font>';
}
$login = User::login();
$id = User::getUID();
if ($login == true) {
echo 'LOGIN: <font color="green">Zalogowano, twoje UID: ' . $id . '</font></br>';
} else {
echo '<font color="red">LOGIN: ERROR!</font></br>';
return false;
}
if (User::checkLogin()) {
echo 'CHECK LOGIN: <font color="green">Zalogowany</font></br>';
} else {
echo 'CHECK LOGIN: <font color="red">Niezalogowany</font></br>';
return false;
}
if ($delete = User::deleteUser() == true) {
echo 'DELETE USER: <font color="green">Usunieto uzytkownika</font></br>';
} else {
echo 'DELETE USER: <font color="red">ERROR</font></br>';
return false;
}
User::logout();
if (!isset($_SESSION["uid"])) {
echo 'LOGOUT: <font color="green">Wylogowano!</font></br>';
} else {
echo 'LOGOUT: <font color="red">ERROR!</font></br>';
return false;
}
return true;
}
示例8: registerAction
public function registerAction()
{
// $formRegister= new Form_User();
$formUser = new Form_User();
$formUser->removeElement('avatar');
$formUser->removeElement('status');
$formUser->removeElement('role');
$formUser->removeElement('profile');
if ($this->getRequest()->isPost()) {
if (!$formUser->isValid($_POST)) {
$userData = $formUser->getValues();
$modelUser = new User();
$newUser = $modelUser->createUser($userData);
if ($newUser) {
$this->_redirect('/user/account/id/' . $newUser);
}
}
}
$this->view->formUser = $formUser;
//$this -> view -> formUser = $formRegister;
}
示例9: pgpSignUp
public function pgpSignUp()
{
if (self::sessionGet('signin_text')) {
return Redirect::to('success');
}
if (Request::isMethod('get')) {
return View::make('auth.signup');
} else {
$input = Input::only('key', 'info');
User::validate($input);
self::botLimit();
$info = $this->checkKey($input['key']);
if (User::where('user_fp', '=', $info['fingerprint'])->first() != NULL) {
return Redirect::to('retrieve');
}
$result = User::createUser($info['fingerprint'], $input);
$this->gpg->addencryptkey($info['fingerprint']);
$text = self::formatSignupText($result['user']->id, $result['priv_hash']);
self::sessionSet('signin_text', $this->gpg->encrypt($text));
return Redirect::to('success');
}
}
示例10: MakeNotification
$notifications[] = MakeNotification("error", Language::Get('main', 'differentPasswords', $langTemplate));
}
} else {
$notifications[] = MakeNotification("error", Language::Get('main', 'incorrectOldPassword', $langTemplate));
}
} else {
$notifications = $notifications + $f->notifications;
}
} else {
if ($_POST['action'] == "SetAccountInfo") {
$f = new FormEvaluator($_POST);
$f->checkStringForKey('language', FormEvaluator::OPTIONAL, 'warning', '???.');
if ($f->evaluate(true)) {
$foundValues = $f->foundValues;
$language = $foundValues['language'];
$newUserSettings = User::encodeUser(User::createUser($uid, null, null, null, null, null, null, null, null, null, null, null, null, null, $language));
$URI = $databaseURI . "/user/" . $uid;
http_put_data($URI, $newUserSettings, true, $message);
if ($message == "201") {
$notifications[] = MakeNotification("success", Language::Get('main', 'languageChanged', $langTemplate));
}
} else {
$notifications = $notifications + $f->notifications;
}
}
}
}
// load user data from the database
$databaseURI = $getSiteURI . "/accountsettings/user/{$uid}";
$accountSettings_data = http_get($databaseURI, true);
$accountSettings_data = json_decode($accountSettings_data, true);
示例11: User
<?php
/**
* Created by PhpStorm.
* User: Dushyant
* Date: 2015-10-30
* Time: 12:00 PM
*/
//user class required
require_once "../../Local/Classes/class.User.inc";
extract($_POST);
if (isset($btnSubmit)) {
$user = new User();
$result = $user->createUser($txtFirstName, $txtLastName, $txtEmail, $txtPassword, $drpUserRole, $txtBirthDate, $rdbGender, $txtCredentials, $txtWorkPhone, $txtCellPhone, $txtFax, $txtAddress, $txtCity, $drpStdProvince, $txtPostalCode, $txtRegistrationNumber, $txtLicenseNumber);
if ($result === true) {
$notifications['addUserSuccess'] = "New user is success fully added";
} else {
$notifications['addUserError'] = $result;
}
}
//include header and sidebar
include "header.php";
include "sidebar.php";
?>
<form role="form" id="frm" method="post" action="<?php
echo $_SERVER['PHP_SELF'];
?>
">
<div class="form-group">
<div id="page-wrapper">
<!--Notifications-->
示例12: actionRegister
public function actionRegister()
{
if (!param('useUserRegistration', 0)) {
throw404();
}
$this->showSearchForm = false;
$this->layout = '//layouts/inner';
if (Yii::app()->user->isGuest) {
if (param('user_registrationMode') == 'without_confirm') {
$model = new User('register_without_confirm');
} else {
$model = new User('register');
}
if (isset($_POST['User']) && BlockIp::checkAllowIp(Yii::app()->controller->currentUserIpLong)) {
$model->attributes = $_POST['User'];
if ($model->validate()) {
$model->activatekey = User::generateActivateKey();
$user = User::createUser($model->attributes);
if ($user) {
$model->id = $user['id'];
$model->password = $user['password'];
$model->email = $user['email'];
$model->username = $user['username'];
$model->activatekey = $user['activatekey'];
$model->activateLink = $user['activateLink'];
$notifier = new Notifier();
$notifier->raiseEvent('onNewUser', $model, array('user' => $user['userModel']));
if (param('user_registrationMode') == 'without_confirm') {
$login = new LoginForm();
$login->setAttributes(array('username' => $user['username'], 'password' => $user['password']));
if ($login->validate() && $login->login()) {
User::updateUserSession();
User::updateLatestInfo(Yii::app()->user->id, Yii::app()->controller->currentUserIp);
$this->redirect(array('/usercpanel/main/index'));
} else {
/*echo 'getErrors=<pre>';
print_r($login->getErrors());
echo '</pre>';
exit;*/
showMessage(Yii::t('common', 'Registration'), Yii::t('common', 'You were successfully registered.'));
}
} else {
showMessage(Yii::t('common', 'Registration'), Yii::t('common', 'You were successfully registered. The letter for account activation has been sent on {useremail}', array('{useremail}' => $user['email'])));
}
} else {
showMessage(Yii::t('common', 'Registration'), Yii::t('common', 'Error. Repeat attempt later'));
}
} else {
$model->unsetAttributes(array('verifyCode'));
}
}
$this->render('register', array('model' => $model));
} else {
$this->redirect('index');
}
}
示例13: function
*/
$app = new \Slim\Slim();
/**
* Step 3: Define the Slim application routes
*
* Here we define several Slim application routes that respond
* to appropriate HTTP request methods. In this example, the second
* argument for `Slim::get`, `Slim::post`, `Slim::put`, `Slim::patch`, and `Slim::delete`
* is an anonymous function.
*/
// GET route
$app->get('/', function () {
//instance of User class
$u = new User();
$conn = $u->connect();
$u->createUser($conn, 'milos', 'babic', '1988-04-15', 'Serbia', 'baki', '123', 'a@a.a');
});
// GET rerister/ registration form
$app->get('/register', function () {
echo "\n <form action='' method='post'>\n <label>first name</label><br />\n <input type='text' name='txt_name' /><br />\n <label>last name</label><br />\n <input type='text' name='txt_surname' /><br />\n <label>date of birth (DD/MM/YYYY)</label><br />\n <input type='text' name='txt_day' /><input type='text' name='txt_mounth' /><input type='text' name='txt_year' /><br />\n <label>coutry</label><br />\n <input type='text' name='txt_country' /><br />\n <label>username</label><br />\n <input type='text' name='txt_username' /><br />\n <label>pasword</label><br />\n <input type='password' name='txt_pass' /><br />\n <label>email</label><br />\n <input type='text' name='txt_email' /><br />\n <input type='submit' name='btn_register' value='register' />\n </form>\n ";
});
// POST route
$app->post('/register', function () {
//db for later check of existing username
$u = new User();
$conn = $u->connect();
//cehck if some post aprams are missing
if (empty($_POST['first_name']) || empty($_POST['last_name']) || empty($_POST['date_of_birth']) || empty($_POST['country']) || empty($_POST['username']) || empty($_POST['password']) || empty($_POST['email'])) {
returnError('Missing or empty post parameters.');
}
//assigning post paramms to variables
示例14: User
<label> Nama Depan : <input type="text" name="fname" required autofocus></label>
</p>
<p>
<label> Nama Belakang : <input type="text" name="lname" required autofocus></label>
</p>
<p>
<label> Username : <input type="text" name="username" required autofocus></label>
</p>
<p>
<label> Password : <input type="password" name="pass" required></label>
</p>
<p>
<label> Profile Picture : <input type="file" name="photo" id="photo" ></label>
</p>
<button type="submit" name="regist">Register</button>
</fieldset>
</form>
</div>
</div>
</body>
</html>
<?php
include 'Loginclass.php';
$user = new User();
if (isset($_POST['regist'])) {
$user->createUser();
}
示例15: test_input
if (empty($_POST["comment"])) {
$comment = " ";
} else {
$comment = test_input($_POST["comment"]);
}
if ($name = "" && ($lastname = "" && $create_email_error == "" && $create_password_error == "" && ($gender = ""))) {
echo "Saab kasutajat luua! Kasutajanimi on " . $create_email . " ja parool on " . $create_password;
$password_hash = hash("sha512", $create_password);
echo "<br>";
echo $password_hash;
//createUser($name, $lastname, $create_email, $password_hash, $age, $gender);
/* $stmt = $mysqli->prepare("INSERT INTO users (name, lastname, email, password, age, gender) VALUES (?, ?, ?, ?, ?, ?)");
$stmt->bind_param("ssssis", $name, $lastname, $create_email, $create_password, $age, $gender);
$stmt->execute();
$stmt->close(); */
$create_response = $User->createUser($name, $lastname, $create_email, $password_hash, $gender);
}
}
// create if end
}
// funktsioon, mis eemaldab koikvoimaliku uleliigse tekstist
function test_input($data)
{
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return $data;
}
// siin kirjutame uut php koogdi
/*
//(kehtestame) m22rame email'i vigu