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


PHP password_encrypt函数代码示例

本文整理汇总了PHP中password_encrypt函数的典型用法代码示例。如果您正苦于以下问题:PHP password_encrypt函数的具体用法?PHP password_encrypt怎么用?PHP password_encrypt使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: attempt_register

function attempt_register($username, $password1, $password2)
{
    $pass1 = trim($password1);
    $pass2 = trim($password2);
    if ($username != "" && $pass1 != "" && $pass2 != "") {
        $user = find_username($username);
        if (!$user) {
            if ($pass1 === $pass2) {
                $encryptedPass = password_encrypt($pass1);
                add_user($username, $encryptedPass);
                return true;
            } else {
                echo "<div id=\"error\">";
                echo "passwords do not match";
                echo "</div>";
            }
        } else {
            echo "<div id=\"error\">";
            echo " this user name has been taken";
            echo "</div>";
        }
    } else {
        echo "<div id=\"error\">";
        echo "please enter all feilds";
        echo "</div>";
    }
}
开发者ID:jorlon,项目名称:TeamWork,代码行数:27,代码来源:function.php

示例2: signin_do

 /**
  * 登录
  * @access  public
  * @return  void
  */
 public function signin_do()
 {
     $username = $_POST['username'];
     $password = $_POST['password'];
     if ($username && $password) {
         $this_user = $this->Mdl_member->my_select_username($username);
         if ($this_user) {
             if ($this_user['status'] == '1') {
                 if ($this_user['password'] == password_encrypt($password)) {
                     $this->session->this_user = $this_user;
                     redirect(site_url('home'));
                 } else {
                     $this->session->set_flashdata('msg', '密码错误');
                 }
             } else {
                 if ($this_user['status'] == '2') {
                     $this->session->set_flashdata('msg', '该账号已锁定');
                 } else {
                     if ($this_user['status'] == '3') {
                         $this->session->set_flashdata('msg', '该账号已注销');
                     }
                 }
             }
         } else {
             $this->session->set_flashdata('msg', '账号不存在');
         }
     } else {
         $this->session->set_flashdata('msg', '用户名密码不能为空');
     }
     redirect(site_url('sign/signin'));
 }
开发者ID:Jiumiking,项目名称:Luck,代码行数:36,代码来源:Sign.php

示例3: do_login

 /**
  * 用户登录验证
  *
  * @access  public
  * @return  void
  */
 public function do_login()
 {
     $username = $_POST['user_name'];
     $password = $_POST['password'];
     if ($username && $password) {
         $this_user = $this->mdl_user->my_select($username);
         if ($this_user) {
             if ($this_user['status'] == '1') {
                 if ($this_user['password'] == password_encrypt($password)) {
                     $this->session->set_userdata('this_user', $this_user);
                     $this->load->model('mdl_log');
                     $this->mdl_log->add_log('登录成功');
                     if ($this_user['password_times'] != '0') {
                         $this->db->where(array('id' => $this_user['id']));
                         $this->db->set('password_times', '0', FALSE);
                         $this->db->update('user');
                     }
                     redirect(site_url('home/index?t=' . time()));
                 } else {
                     $setting_times = empty($this->this_setting['user_error_times']) ? 5 : $this->this_setting['user_error_times'];
                     $this->db->where(array('id' => $this_user['id']));
                     $this->db->set('password_times', 'password_times + 1', FALSE);
                     if ($this_user['password_times'] + 1 >= $setting_times) {
                         $this->db->set('status', '2');
                         $msg = '密码错误,该账号已锁定';
                     } else {
                         $msg = '密码错误,错误' . ($setting_times - ($this_user['password_times'] + 1)) . '次后锁定';
                     }
                     $this->db->update('user');
                     $this->session->set_flashdata('msg', $msg);
                 }
             } else {
                 if ($this_user['status'] == '2') {
                     $this->session->set_flashdata('msg', '该账号已锁定');
                 } else {
                     if ($this_user['status'] == '3') {
                         $this->session->set_flashdata('msg', '该账号已注销');
                     }
                 }
             }
         } else {
             $this->session->set_flashdata('msg', '账号不存在');
         }
     } else {
         $this->session->set_flashdata('msg', '用户名密码不能为空');
     }
     redirect(site_url('login'));
 }
开发者ID:Jiumiking,项目名称:qw,代码行数:54,代码来源:Login.php

示例4: createTempUsers

 /**
  * 테스트용 임시 사용자 생성.
  *
  * @usage php index.php "route=user.Test.createTempUsers"
  *
  */
 public function createTempUsers()
 {
     $user = array();
     $sec = date('his');
     for ($i = 1; $i <= 100; $i++) {
         $user['username'] = "Username({$sec}){$i}";
         $user['password'] = password_encrypt("Username{$i}");
         $user['email'] = "email({$sec}){$i}@gmail.com";
         $o = user()->create()->sets($user)->save();
         if ($o == FALSE) {
             die("ERROR on creating Users.");
         } else {
             echo $o->get('id') . ' ';
         }
     }
 }
开发者ID:thruthesky,项目名称:backend,代码行数:22,代码来源:Test.php

示例5: register

 public static function register(array $login_array, array $customer_array)
 {
     global $database;
     $hash = password_encrypt($login_array['password']);
     foreach ($customer_array as $field => $value) {
         $customer_array[$field] = $database->escape_value($value);
     }
     $sql = "INSERT INTO customers ";
     $sql .= "(forename, surename, company, street, city, postcode, phone, email) ";
     $sql .= "VALUES ( '{$customer_array['forename']}', '{$customer_array['surename']}', '{$customer_array['company']}', '{$customer_array['street']}', '{$customer_array['city']}', '{$customer_array['postcode']}', '{$customer_array['phone']}', '{$customer_array['email']}') ";
     $database->query($sql);
     // get id for the new customer
     $sql = "SELECT * FROM customers ORDER BY id DESC LIMIT 1";
     $result_array = $database->fetch_array($database->query($sql));
     $sql = "INSERT INTO logins ";
     $sql .= "(customer_id, username, password, password_change, admin_rights) ";
     $sql .= "VALUES ({$result_array['id']}, '{$login_array['username']}', '{$hash}', {$login_array['password_change']}, {$login_array['admin_rights']}) ";
     $database->query($sql);
 }
开发者ID:ZettaKonsult,项目名称:Landins,代码行数:19,代码来源:user.php

示例6: redirect_to

if (!isset($_SESSION["User"])) {
    redirect_to("login.php");
    // Redirect if not proper GET
} elseif (!isset($_GET["ID"])) {
    redirect_to("profile.php");
}
// Process user editing form
if (isset($_POST["submit"])) {
    $ID = $_GET["ID"];
    $Password = mysql_prep($_POST["Password"]);
    $PassConfirm = mysql_prep($_POST["PassConfirm"]);
    if ($Password != $PassConfirm) {
        $_SESSION["failMsg"] = "Новый пароль и пароль потверждении не совпадали.";
        redirect_to("profile.php?account");
    } else {
        $hashed_password = password_encrypt($Password);
        $query = "UPDATE user SET ";
        $query .= "Password = '{$hashed_password}' ";
        $query .= "WHERE ID = {$ID}";
        $result = mysqli_query($connection, $query);
        if ($result && mysqli_affected_rows($connection) == 1) {
            $_SESSION["succMsg"] = "Изменении успешно сохранены.";
            redirect_to("profile.php?basic");
        } else {
            $_SESSION["failMsg"] = "Ошибка изменении.";
            redirect_to("profile.php");
        }
    }
}
include "../../includes/layouts/header.php";
?>
开发者ID:kerimgrozny,项目名称:kerimgrozny,代码行数:31,代码来源:edit_user2.php

示例7: redirect_to

<?php

require_once '../../includes/initialize.php';
if (!$session->is_logged_in() || $_SESSION['role'] != "admin") {
    redirect_to("login.php");
}
if (isset($_POST['submit'])) {
    $user = new User();
    $user->username = $_POST['username'];
    $user->password = password_encrypt($_POST['password']);
    $user->first_name = $_POST['first_name'];
    $user->last_name = $_POST['last_name'];
    $user->role = strtolower($_POST['role']);
    $user->department = strtolower($_POST['department']);
    $user->created_by = (int) $_SESSION['user_id'];
    $user->created = strftime("%Y-%m-%d %H:%M:%S", time());
    if ($user->save()) {
        // Success
        $session->message("User created successfully.");
        redirect_to('index.php');
    } else {
        // Failure
        $session->message("User creation failed.");
        redirect_to('index.php');
    }
}
?>

<?php 
include_layout_template('admin_header.php');
?>
开发者ID:aluck19,项目名称:assignment2Do,代码行数:31,代码来源:users.php

示例8: array

<?php 
if (isset($_POST['submit'])) {
    // Process the form
    // validations
    $required_fields = array("username", "password", "email");
    $_POST["username"] = $admin["username"];
    validate_presences($required_fields);
    $fields_with_max_lengths = array("username" => 30);
    validate_max_lengths($fields_with_max_lengths);
    validate_email(array("email"));
    if (empty($errors)) {
        // Perform Update
        $id = $admin["id"];
        $username = mysql_prep($admin["username"]);
        $hashed_password = password_encrypt($_POST["password"]);
        $email = mysql_prep($_POST["email"]);
        $user_type = mysql_prep($_POST["user_type"]);
        $nom = mysql_prep($admin["nom"]);
        $query = "UPDATE admins SET" . " ";
        //$query .= "username = '{$username}', ";
        $query .= "hashed_password = '{$hashed_password}', ";
        $query .= "email = '{$email}', ";
        //$query .= "user_type = '{$user_type}', ";
        $query .= "nom = '{$nom}' ";
        $query .= "WHERE id = {$id} ";
        $query .= "LIMIT 1";
        $result = mysqli_query($connection, $query);
        if ($result && mysqli_affected_rows($connection) == 1) {
            // Success
            $_SESSION["message"] = "New info updated sucessfully.";
开发者ID:kamy333,项目名称:kamy,代码行数:30,代码来源:edit_admin_individual.php

示例9: password_update

function password_update($username, $password)
{
    global $db;
    $hash = password_encrypt($password);
    $query = "UPDATE logins ";
    $query .= "SET password_change = 0, ";
    $query .= "password='{$hash}' ";
    $query .= "WHERE username = '{$username}'";
    $update_result = database_query($query);
}
开发者ID:ZettaKonsult,项目名称:Landins,代码行数:10,代码来源:functions.php

示例10: update_pwd

 /**
  * ajax修改密码
  *
  * @access  public
  * @return  void
  */
 public function update_pwd()
 {
     if (empty($_GET['id']) || empty($_GET['pwd'])) {
         echo 2;
         exit;
     }
     $user_data['password'] = password_encrypt($_GET['pwd']);
     if ($this->mdl_user->my_update($_GET['id'], $user_data)) {
         echo 1;
         exit;
     }
     echo 2;
 }
开发者ID:Jiumiking,项目名称:qw,代码行数:19,代码来源:User.php

示例11: mysqli_query

global $message;
$oldusername = "";
$oldpassword = "";
if (isset($_GET['admin'])) {
    $id = $_GET['admin'];
    $q1 = "SELECT * from admins where id = " . $id . "";
    $res = mysqli_query($connection, $q1);
    while ($oldinfo = mysqli_fetch_assoc($res)) {
        $id = $oldinfo['id'];
        $oldusername = $oldinfo['username'];
        $oldpassword = $oldinfo['password'];
    }
    if (isset($_POST['submit'])) {
        echo "<h1> HERE</h1>";
        $username = $_POST['newuser'];
        $password = password_encrypt($_POST['newpass']);
        $query = "UPDATE admins\nSET username='" . $username . "', password='" . $password . "'\nWHERE id='" . $id . "';";
        $result = mysqli_query($connection, $query);
        //this is excuted in case of insert and delete and update as well
        if ($result) {
            $message = "Success";
            //file_put_contents("1.txt",$query);
            redirect_to("manage_admins.php");
        } else {
            $message = "There was an error with your edit";
        }
    }
} else {
    // redirect_to("manage_admins.php");
}
echo $message;
开发者ID:bi6o,项目名称:HumanToHuman,代码行数:31,代码来源:edit_admin.php

示例12: sqlsrv_query

<?php 
if (isset($_POST['submit'])) {
    $Username = $_POST['username'];
    $Password = $_POST['password'];
    $ConfirmPassword = $_POST['confirmPassword'];
    if ($Password != $ConfirmPassword) {
        $Message = "\n\t\t  <div class='alert alert-danger' role='alert'>\n\t\t      Passwords don't match. Please enter again'\n\t\t  </div>";
    } else {
        $sql = "SELECT * FROM users WHERE username = '{$Username}'";
        $usernameCheck = sqlsrv_query($conn, $sql) or die("Query to check if username exists failed");
        confirm_query($usernameCheck);
        if (!null == sqlsrv_fetch_array($usernameCheck)) {
            $Message = "\n\t\t  <div class='alert alert-danger' role='alert'>\n\t\t      Username already in use. Please choose another\n\t\t  </div>";
        } else {
            /// Hash and salt the password
            $Password = password_encrypt($Password);
            ///Process the query then redirect if successful
            $query = "INSERT INTO users (username, password) VALUES ('{$Username}','{$Password}')";
            $result = sqlsrv_query($conn, $query) or die('Error: insert query failed');
            $_SESSION['username'] = $_POST['username'];
            redirect('home.php');
        }
    }
} else {
    $Username = "";
    $Password = "";
    $ConfirmPassword = "";
}
?>

	<body>
开发者ID:pejhmon,项目名称:test,代码行数:31,代码来源:registration.php

示例13: sql_query

//check if user exists already
$sql = sql_query(" SELECT id FROM `users` WHERE email='{$email1}' LIMIT 1 ");
if (sql_count($sql) > 0) {
    notices_set('Email already in use, please use a different email or reset your password', 'error');
    $terror = true;
}
//last error check
if ($terror) {
    //exit script
    echo notices_get();
    return false;
}
//create password
$hash_token = password_hash_create();
//creates a users unique hash
$password = password_encrypt($password1, $hash_token);
//create account confirm
$confirm = confirm_token_create($email1);
//add to database
sql_query(" INSERT INTO `users` (hash_token, email, password, confirm) VALUES('{$hash_token}', '{$email1}', '{$password}', '{$confirm}') ");
//set notices
notices_set('Account successfully created!', 'success');
//send email
email_send('register', 'Welcome to Planling!', array($email1 => $email1), array('{{%LINK%}}' => 'http://' . MAIN_URL . '/verify?e=' . $email1 . '&t=' . $confirm));
//log the user in
if (do_login($email1, $password1)) {
    $main_data = set_main_data();
} else {
    return false;
}
//success
开发者ID:dangledorf,项目名称:Planling,代码行数:31,代码来源:register.php

示例14: find_admin_by_username

<h4 class="text-center"><mark><a href="<?php 
echo $_SERVER["PHP_SELF"];
?>
">my modele</a> </mark></h4>

<?php 
$admin = find_admin_by_username("kamy");
//foreach($admin as $key=>$val){
//    echo $key." :".$val."<br>";
//}
echo " database hashed :<br>" . $admin["hashed_password"] . "<br>";
$existing_password = $admin["hashed_password"];
$password = "kamy";
$existing_password = password_encrypt($password);
echo " password encrypt :<br>" . $existing_password . "<br>";
$existing_password = password_encrypt($password);
echo " password encrypt :<br>" . $existing_password . "<br>";
$check = password_check($password, $existing_password);
echo "<br>";
if ($check) {
    echo "password match";
} else {
    echo "password did not match";
}
//var_dump($admin);
?>


<?php 
include "../includes/layouts/footer_2.php";
开发者ID:kamy333,项目名称:kamy,代码行数:30,代码来源:5_modele.php

示例15: createUser

function createUser($username, $password, $name, $phone_no, $email)
{
    global $connection;
    $safe_username = mysql_prep($username);
    $safe_email = mysql_prep($email);
    $hashed_password = password_encrypt($password);
    $query = "INSERT INTO ";
    $query .= "user_auth (user_id,password) ";
    $query .= "VALUES (";
    $query .= " '{$safe_username}','{$hashed_password}'";
    $query .= "); ";
    //$result=mysqli_query($connection,$query);
    //echo "$query";
    $query .= "INSERT INTO ";
    $query .= "user_details (user_id,full_name,phone_no,email) ";
    $query .= "VALUES (";
    $query .= " '{$username}','{$name}','{$phone_no}','{$safe_email}'";
    $query .= ");";
    //echo "$query";
    $result = mysqli_multi_query($connection, $query);
    if (!$result) {
        echo "Query failed";
    }
    return $result;
}
开发者ID:arnavprospeed,项目名称:Assignment_17_08_2015,代码行数:25,代码来源:functions_repo.php


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