当前位置: 首页>>代码示例>>PHP>>正文


PHP Users::insert方法代码示例

本文整理汇总了PHP中Users::insert方法的典型用法代码示例。如果您正苦于以下问题:PHP Users::insert方法的具体用法?PHP Users::insert怎么用?PHP Users::insert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Users的用法示例。


在下文中一共展示了Users::insert方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: pdoAddModelAction

 public function pdoAddModelAction()
 {
     $this->_view->title = 'Model Add Form';
     $this->_view->link = base_url() . 'pdo-database/pdo-model/pdo-add-model';
     $val = new Validation();
     $val->source = $_POST;
     if (!empty($_POST)) {
         $val = new Validation();
         $val->source = $_POST;
         $val->addValidator(array('name' => 'first_name', 'type' => 'string', 'required' => true));
         $val->addValidator(array('name' => 'last_name', 'type' => 'string', 'required' => true));
         $val->addValidator(array('name' => 'email', 'type' => 'email', 'required' => true));
         $val->addValidator(array('name' => 'address', 'type' => 'string', 'required' => true));
         $val->run();
         if (!$val->hasError()) {
             $users = new Users();
             $data = array('first_name' => $_POST['first_name'], 'last_name' => $_POST['last_name'], 'email' => $_POST['email'], 'address' => $_POST['address']);
             $users->insert($data);
             redirect('pdo-database/pdo-model/pdo-model');
         }
         $this->_view->errorMessage = $val->errorMessage();
         $this->_view->data = $_POST;
     }
     $this->renderView('pdo-database/pdo-model/_form');
 }
开发者ID:ngukho,项目名称:mvc-cms,代码行数:25,代码来源:PdoModelController.php

示例2: register

 public function register(UI\Form $form)
 {
     try {
         $values = $form->getValues();
         $unhash_password = $values->password;
         $values->password = $this->users->calculateHash($values->password);
         $values->hash = sha1($values->username . $values->password);
         unset($values['agree']);
         $this->users->insert($values);
         $template = $this->createTemplate();
         $template->setFile(__DIR__ . "/../templates/Sign/mail-confirmation.latte");
         $template->setTranslator($this->translator);
         $template->hash = $values->hash;
         $msg = new \Nette\Mail\Message();
         $msg->setHtmlBody($template)->setFrom('noreply@peknyden.cz')->setSubject('Potvrzení registrace na portálu Peknyden.cz')->addTo(trim($values->email));
         $this->mailer->send($msg);
     } catch (Exception $e) {
         error_log($e->getMessage());
         switch ($e->getCode()) {
             case "23000":
                 $form->addError('There is account with this username or e-mail. Please select different one.');
                 break;
             default:
                 $form->addError('There is some error. Our administrator was informed.', 'error');
                 throw new Exception($e->getMessage());
         }
     }
     if ($form->isSuccess()) {
         $this->cleanCache('users', 'user');
         $this->flashMessage('Výborně, jste úspěšně zaregistrováni. Zkontrolujte váš e-mail!', 'success');
         $this->logUser($values->username, $unhash_password, null, true);
     }
 }
开发者ID:soundake,项目名称:pd,代码行数:33,代码来源:SignPresenter.php

示例3: create_user

 public function create_user()
 {
     // If there are no users then let's create one.
     $db = Database::get_instance();
     $db->query('SELECT * FROM `users` LIMIT 1');
     if ($db->has_rows() && !Auth::get_instance()->logged_in()) {
         Flash::set('<p class="flash validation">Sorry but to create new users, you must be logged in.</p>');
         Core_Helpers::redirect(WEB_ROOT . 'login/');
     }
     $validator = Error::instance();
     if (isset($_POST['email'])) {
         $validator->email($_POST['email'], 'email');
         $validator->blank($_POST['username'], 'username');
         $validator->blank($_POST['password'], 'password');
         $validator->passwords($_POST['password'], $_POST['confirm_password'], 'confirm_password');
         $user = new Users();
         if ($user->select(array('username' => $_POST['username']))) {
             $validator->add('username', 'The username <strong>' . htmlspecialchars($_POST['username']) . '</strong> is already taken.');
         }
         if ($validator->ok()) {
             $user = new Users();
             $user->load($_POST);
             $user->level = 'admin';
             $user->insert();
             Flash::set('<p class="flash success">User created successfully.</p>');
             Core_Helpers::redirect(WEB_ROOT . 'login/');
         }
     }
     $this->data['error'] = $validator;
     $this->load_template('create_user');
 }
开发者ID:robv,项目名称:konnect,代码行数:31,代码来源:controller.main.php

示例4: create

 public static function create()
 {
     !$_SESSION['id'] ? static::isRobot() : null;
     static::purifier();
     if ($_POST['name'] != "" && $_POST['email'] != "" && $_POST['course'] != "" && $_POST['phone'] != "" && $_POST['semester'] != "" && $_POST['registry'] != "") {
         $user = new Users($_POST);
         try {
             $user->insert();
             $_SESSION['msg'] = 'success">Cadastro realizado com sucesso!';
             $email = new Email($_POST);
             $email->send();
         } catch (pdoexception $e) {
             $_SESSION['msg'] = 'fail">Erro ao cadastrar. Confira as informações inseridas.';
         }
     }
     isset($_SESSION['id']) ? header('Location: ../views/subscribers') : header('Location: ../#subscribe');
 }
开发者ID:InfoJrUFBA,项目名称:git-github,代码行数:17,代码来源:user.php

示例5: actionRegisting

 public function actionRegisting()
 {
     $Users = new Users();
     $data = $this->Common->getFilter($_POST);
     if (empty($data['email'])) {
         $this->Common->exportResult(false, '请输入邮箱!');
     }
     if (empty($data['password'])) {
         $this->Common->exportResult(false, '请输入密码!');
     }
     $data['add_date'] = $this->Common->getDate();
     $data['password'] = md5($data['password']);
     if ($Users->insert($data)) {
         $this->Common->exportResult(true, '注册成功!');
     } else {
         $this->Common->exportResult(false, '注册失败!');
     }
 }
开发者ID:mamtou,项目名称:wavephp,代码行数:18,代码来源:SiteController.php

示例6: usersAction

 /**
  * Page
  */
 public function usersAction()
 {
     $usersModel = new Users();
     if ($this->getRequest()->isPost()) {
         $data = $this->getRequest()->getPost();
         if (@$data['method'] == 'create') {
             //CREATE NEW USER
             unset($data['method']);
             if ($data['email'] == '' || $data['password'] == '') {
                 $this->view->error = "Please complete all fields.";
                 $this->view->data = $data;
             } else {
                 $data['password'] = sha1($data['password']);
                 $usersModel->insert($data);
                 $this->view->success = "New User Created.";
             }
         }
         if (@$data['method'] == 'update') {
             //UPDATE USER
             unset($data['method']);
             if ($data['password'] == '') {
                 unset($data['password']);
             } else {
                 $data['password'] = sha1($data['password']);
             }
             $usersModel->updateRecord($data['id'], $data);
             $this->view->success = "User Record Updated.";
         }
         if (@$data['method'] == 'delete') {
             //DELETE USER
             $where = "id=" . $data['id'];
             $usersModel->delete($where);
         }
     }
     $users = $usersModel->getAll();
     $page = $this->_getParam('page', 1);
     $paginator = Zend_Paginator::factory($users);
     $paginator->setItemCountPerPage(20);
     $paginator->setCurrentPageNumber($page);
     $this->view->users = $paginator;
     $locationsModel = new Locations();
     $this->view->locations = $locationsModel->getAll();
 }
开发者ID:tolya199178,项目名称:swift,代码行数:46,代码来源:AdminController.php

示例7: insertProcess

function insertProcess()
{
    $valid = Validator::make(array('send.firstname' => 'min:1|slashes', 'send.lastname' => 'min:1|slashes', 'send.groupid' => 'number|slashes', 'send.username' => 'min:3|slashes', 'send.email' => 'email|slashes', 'address.address_1' => 'slashes', 'address.address_2' => 'slashes', 'address.city' => 'slashes', 'address.state' => 'slashes', 'address.postcode' => 'slashes', 'address.country' => 'slashes'));
    if (!$valid) {
        throw new Exception("Error Processing Request: " . Validator::getMessage());
    }
    $username = Request::get('send.username');
    $email = Request::get('send.email');
    $loadData = Users::get(array('where' => "where username='{$username}' OR email='{$email}'"));
    if (isset($loadData[0]['userid'])) {
        throw new Exception("This user have been exist in database.");
    }
    $send = Request::get('send');
    $address = Request::get('address');
    $thepass = Request::get('thepass');
    $passMd5 = String::encrypt($thepass);
    $send['password'] = $passMd5;
    $address['firstname'] = $send['firstname'];
    $address['lastname'] = $send['lastname'];
    $userid = Users::insert($send);
    $address['userid'] = $userid;
    Address::insert($address);
}
开发者ID:neworldwebsites,项目名称:noblessecms,代码行数:23,代码来源:users.php

示例8: action

 public function action()
 {
     // load
     $this->load->model('Users');
     // variables
     $username = $_POST['username'];
     $password = $_POST['password'];
     $confirm_password = $_POST['confirm_password'];
     $target_dir = base_url() . 'assets/images/';
     //var_dump($avatar);
     // if the username exist in database return to register page
     if ($this->Users->check_username($username) != null) {
         redirect('register');
     } else {
         if ($password != $confirm_password) {
             redirect('register');
         } else {
             if (getimagesize($_FILES["avatar"]["tmp_name"]) == false) {
                 redirect('register');
             }
         }
     }
     // check if file is too big
     if ($_FILES["avatar"]["size"] > 500000) {
         redirect('register');
     } else {
         $user = new Users();
         $user->username = $username;
         $user->password = hash('md5', $password);
         $user->avatar = 'something';
         $user->isAdmin = false;
         $user->insert();
         // move_uploaded_file($_FILES["avatar"]["tmp_name"], "assets/images/" . ($user->get_largest_id() + 1));
         redirect('login');
     }
 }
开发者ID:COMP4711StockTicker,项目名称:Assignment1,代码行数:36,代码来源:Register.php

示例9: actionModified

 /**
  * 提交信息
  */
 public function actionModified()
 {
     $data = $this->Common->getFilter($_POST);
     $userid = (int) $data['userid'];
     unset($data['userid']);
     $Users = new Users();
     if ($userid == 0) {
         unset($data['oldemail']);
         $count = $Users->getCount('*', array('email' => $data['email']));
         if ($count > 0) {
             $this->jumpBox('邮箱不能重复!', Wave::app()->homeUrl . 'users', 1);
         }
         $data['password'] = md5($data['password']);
         $data['add_date'] = date('Y-m-d H:i:s');
         $userid = $Users->insert($data);
         $data['userid'] = $userid;
         $this->Log->saveLogs('添加用户', 1, $data);
     } else {
         if ($data['oldemail'] != $data['email']) {
             $count = $Users->getCount('*', array('email' => $data['email']));
             if ($count > 0) {
                 $this->jumpBox('邮箱不能重复!', Wave::app()->homeUrl . 'users', 1);
             }
         }
         unset($data['oldemail']);
         if (!empty($data['password'])) {
             $data['password'] = md5($data['password']);
         } else {
             unset($data['password']);
         }
         $Users->update($data, array('userid' => $userid));
         $data['userid'] = $userid;
         $this->Log->saveLogs('更新用户', 1, $data);
     }
     $this->jumpBox('成功!', Wave::app()->homeUrl . 'users', 1);
 }
开发者ID:mamtou,项目名称:wavephp,代码行数:39,代码来源:UsersController.php

示例10: insertUser

 public static function insertUser()
 {
     return Users::insert(array('email' => Input::get('email'), 'username' => Input::get('username'), 'password' => Hash::make(Input::get('password')), 'created_at' => date('Y-m-d H:i:s'), 'updated_at' => date('Y-m-d H:i:s')));
 }
开发者ID:srsajid,项目名称:laravel-img-upload,代码行数:4,代码来源:Users.php

示例11: testdataAction

 function testdataAction()
 {
     $request = new Bolts_Request($this->getRequest());
     if ($this->getRequest()->isPost()) {
         $errors = array();
         $data_path = $request->data_path;
         $data_file = $data_path . "/users.dat";
         $image_dir = $data_path . "/images";
         $users_table = new Users();
         $users_roles_table = new UsersRoles();
         if ($request->has("email_domain")) {
             $email_domain = $request->email_domain;
         } else {
             $email_domain = "nowhere.com";
         }
         if (!file_exists($data_file)) {
             $errors[] = $this->_T("Data file missing. Check path.");
         } else {
             $users = unserialize(file_get_contents($data_file));
             if (!is_array($users)) {
                 $errors[] = $this->_T("Data file is corrupt or something.");
             }
         }
         if (count($errors) == 0) {
             $old_users = $users_table->fetchAll();
             foreach ($old_users as $old_user) {
                 if ($users_table->getMetaData($old_user->username, "is_test_user") == "true") {
                     $where = $users_table->getAdapter()->quoteInto("username = ?", $old_user->username);
                     $users_table->delete($where);
                     $users_roles_table->delete($where);
                 }
             }
             $count = 0;
             foreach ($users as $user) {
                 $tmp_user = array();
                 foreach ($user as $key => $value) {
                     if ($key != "avatar") {
                         $tmp_user[$key] = $value;
                     }
                 }
                 $tmp_user['email'] = strtolower($tmp_user['username'] . "@" . $email_domain);
                 $tmp_user['password'] = "password";
                 $destination_path = $users_table->getAvatarPath($user['username']);
                 $destination_filename = $users_table->getAvatarPath($user['username'], true);
                 if (!is_dir($destination_path)) {
                     mkdir($destination_path, 0777, true);
                 }
                 if (file_exists($destination_filename)) {
                     unlink($destination_filename);
                 }
                 $source_image = $image_dir . "/" . $user['avatar'];
                 copy($source_image, $destination_filename);
                 $role_data = array("username" => $tmp_user['username'], "role_id" => $tmp_user['role_id']);
                 $users_roles_table->insert($role_data);
                 unset($tmp_user['role_id']);
                 $users_table->insert($tmp_user);
                 $users_table->setMetaData($tmp_user['username'], "is_test_user", "true");
                 $save_users[] = $user;
                 $count++;
             }
             $this->view->success = "User data loaded. Created " . $count . " users.";
             Bolts_Registry::set('test_data_path', $request->data_path);
             $this->view->data_path = Bolts_Registry::get('test_data_path');
             $this->view->email_domain = $email_domain;
         } else {
             $this->view->errors = $errors;
             $this->view->data_path = Zend_Registry::get('basepath') . "/tmp/testdata";
             $this->view->email_domain = $request->email_domain;
         }
     } else {
         $this->view->data_path = Zend_Registry::get('basepath') . "/tmp/testdata";
         $this->view->email_domain = "nowhere.com";
         $this->view->notice = $this->_T("Warning: If you are reinstalling the test data, the old test data will be overwritten. Users created outside the test data should not be affected.");
     }
 }
开发者ID:jaybill,项目名称:Bolts,代码行数:75,代码来源:UseradminController.php

示例12: makeRegister

 public static function makeRegister($inputData = array())
 {
     if (!isset($_REQUEST['send']['firstname']) && isset($inputData['firstname'])) {
         $_REQUEST['send'] = $inputData;
     }
     $valid = Validator::make(array('send.firstname' => 'required|min:1|max:20|slashes', 'send.lastname' => 'required|min:1|max:20|slashes', 'send.username' => 'required|min:1|max:30|slashes', 'send.email' => 'required|email|max:120|slashes', 'send.password' => 'required|min:1|max:30|slashes'));
     if (!$valid) {
         throw new Exception("Check your infomartion again: " . Validator::getMessage());
     }
     $insertData = Request::get('send');
     if (!($id = Users::insert($insertData))) {
         throw new Exception("Check your infomartion again, pls!");
     }
     $addData = array('firstname' => trim($insertData['firstname']), 'lastname' => trim($insertData['lastname']), 'userid' => $id);
     Address::insert($addData);
     try {
         self::newRegister($insertData);
     } catch (Exception $e) {
         throw new Exception($e->getMessage());
     }
 }
开发者ID:neworldwebsites,项目名称:noblessecms,代码行数:21,代码来源:Users.php

示例13: date

     $email = $app->request->post('email');
     $created_at = date('Y-m-d H:i:s');
     if ($username == "") {
         $app->flash('error', 1);
         $app->redirect($settings->base_url . '/admin/users/new');
     }
     if ($password == "") {
         $app->flash('error', 2);
         $app->redirect($settings->base_url . '/admin/users/new');
     }
     if ($email == "" or !filter_var($email, FILTER_VALIDATE_EMAIL)) {
         $app->flash('error', 3);
         $app->redirect($settings->base_url . '/admin/users/new');
     }
     $redirect = $settings->base_url . '/admin/users';
     Users::insert(array('username' => $username, 'password' => $password, 'email' => $email, 'created_at' => $created_at));
     $app->render('success.html', array('redirect' => $redirect));
 });
 $app->get('/posts/activate/:id', $authenticate($app, $settings), function ($id) use($app, $settings) {
     $post = Posts::where('id', '=', $id)->first();
     if ($post) {
         $redirect = $settings->base_url . '/admin';
         $post->update(array('active' => 'true'));
         $app->render('success.html', array('redirect' => $redirect));
     } else {
         $app->render('404_post.html');
     }
 })->conditions(array('id' => '\\d+'));
 $app->get('/posts/deactivate/:id', $authenticate($app, $settings), function ($id) use($app, $settings) {
     $post = Posts::where('id', '=', $id)->first();
     if ($post) {
开发者ID:kuslahne,项目名称:SlimBlog,代码行数:31,代码来源:admin.route.php

示例14: Users

                // $json_response = json_encode($response);
                // echo $json_response;
            }
        }
    } else {
        //insert action
        $user = new Users();
        $user->name = $_POST['name'];
        $user->birthday = $_POST['birthday'];
        $user->address = $_POST['address'];
        $user->username = $_POST['username'];
        $user->email = $_POST['email'];
        $user->password = $_POST['password'];
        $user->credit = $_POST['credit'];
        $user->image = $_POST['image'];
        $user->id = $user->insert();
        if ($user->id > 0) {
            // $status=200;
            $response['data'] = array('user_id' => $user->id);
            $rest = new User_server();
            $rest->handle_response($response['data'], 200);
            // $response['status'] = 'OK';
            // $json_response = json_encode($response);
            // echo $json_response;
        }
    }
    //get user either with id or all
} else {
    if ($_method == 'GET') {
        // get user with a specific id
        if (isset($_GET['id'])) {
开发者ID:todary,项目名称:Eshopper,代码行数:31,代码来源:user.php

示例15: addModelAction

 public function addModelAction()
 {
     $this->_view->title = 'Model Add Form';
     $this->_view->link = base_url() . 'database/model/add-model';
     $val = new Validation();
     $val->source = $_POST;
     if (!empty($_POST)) {
         $val = new Validation();
         $val->source = $_POST;
         $val->addValidator(array('name' => 'first_name', 'type' => 'string', 'required' => true));
         $val->addValidator(array('name' => 'last_name', 'type' => 'string', 'required' => true));
         $val->addValidator(array('name' => 'email', 'type' => 'email', 'required' => true));
         $val->addValidator(array('name' => 'address', 'type' => 'string', 'required' => true));
         $val->run();
         if (sizeof($val->errors) == 0) {
             $users = new Users();
             $users->addValue('first_name', $_POST['first_name']);
             $users->addValue('last_name', $_POST['last_name']);
             $users->addValue('email', $_POST['email']);
             $users->addValue('address', $_POST['address']);
             $users->insert();
             redirect('database/model/model');
         }
         $this->_view->errorMessage = $val->errorMessage();
         $this->_view->data = $_POST;
     }
     $this->renderView('database/model/_form');
 }
开发者ID:ngukho,项目名称:mvc-cms,代码行数:28,代码来源:ModelController.php


注:本文中的Users::insert方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。