0
控制器:在codeigniter中創建高安全的加密id到網站url?
function verifyuser()
{
$uri = $this->uri->uri_to_assoc(4);
//print_r($uri);
if(isset($uri['id']) && $uri['id'] != '')
{
$where = array();
$where['roll_number'] = $uri['id'];
$this->data['verification'] = $this->admin_model->verify($where);
}
else
{
$this->data['verification'] = array();
}
$this->data['content'] = 'admin/verification';
$this->view($this->data);
}
MODEL:
function verify($where='')
{
$this->db->select('*');
$this->db->from($this->db->dbprefix('members'));
if(!(empty($where)))
$this->db->where($where);
$result = $this->db->get();
//echo $this->db->last_query();
return $result->result();
}
www.example.com/user/admin/verify/
到
www.example.com/user/admin/驗證/ hgf_877 %%% _ oi
這樣。
更安全的方法是使用用戶名/密碼組合和驗證用戶。如果你仍然想按照你的方式來實現它,那麼只需要生成一個隨機單詞,使用bcrypt或sha1對它進行加密並在網址中使用它。 – ahmad 2013-02-12 15:12:25