本文整理汇总了PHP中Hash::create_hash方法的典型用法代码示例。如果您正苦于以下问题:PHP Hash::create_hash方法的具体用法?PHP Hash::create_hash怎么用?PHP Hash::create_hash使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Hash
的用法示例。
在下文中一共展示了Hash::create_hash方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: editSave
public function editSave($id)
{
$data = array();
$data['user_id'] = $id;
$data['login'] = trim($_POST['login']);
$data['password'] = Hash::create_hash('md5', trim($_POST['password']), HASH_KEY);
$data['role'] = trim($_POST['role']);
///print_r($data); die;
$this->model->editUser($data);
header('Location: ' . URL . 'user');
}
示例2: editUser
public function editUser($data)
{
//echo $data['role']; die;
$postData = array('login' => $data['login'], 'password' => Hash::create_hash('md5', $data['password'], HASH_PASSWORD_KEY), 'role' => $data['role']);
$this->db->update('users', $postData, "`id` = {$data['user_id']}");
// $stm = $this->db->prepare("UPDATE users
// SET login = :login,
// password = :password,
// role = :role
// WHERE id = :id");
//
// //var_dump($stm);die;
// $stm->execute(array(
// ':id' => $data['id'],
// ':login' => $data['login'],
// ':password' => $data['password'],
// ':role' => $data['role']
// ));
}
示例3: runLogin
public function runLogin()
{
$stm = $this->db->prepare("SELECT user_id, role from users WHERE login = :login\n AND password = :password");
$stm->execute(array(':login' => $_POST['login'], ':password' => Hash::create_hash('md5', $_POST['password'], HASH_KEY)));
//var_dump($stm); die();
$stm->setFetchMode(PDO::FETCH_ASSOC);
$data = $stm->fetch();
//var_dump($stm); die();
$count = $stm->rowCount();
//var_dump($count); die();
if ($count > 0) {
//login
Session::set('role', $data['role']);
Session::set('loggedIn', true);
Session::set('user_id', $data['user_id']);
header('location: ../dashboard');
} else {
//show an error
header('location: ../login');
}
}
示例4: index
function index()
{
echo Hash::create_hash('md5', 'secret', HASH_KEY);
$this->view->render('login/index');
}