Welcome Guest, Not a member yet? Register   Sign In
Delete from database ONLY if the uid from the database matches the uid in session
#3

(This post was last modified: 03-03-2015, 06:03 AM by _this.)

Perfect solution, was planning to answer the same while reading post on homepage ^^

You just made a little mistake :

PHP Code:
$this->session->set_userdate('uid'$userid); 

Should be :

PHP Code:
$this->session->set_userdata('uid'$userid); 

And it's more secure (to me) to make a check before accessing a session var :

PHP Code:
if($this->session->userdata('uid') === false) {
    
// Throw error
} else {
    
$this->db->where('pid'$pid)
             ->
where('uid'$this->session->userdata('uid'))
             ->
delete('dayone_entries');

Reply


Messages In This Thread
RE: Delete from database ONLY if the uid from the database matches the uid in session - by _this - 03-03-2015, 06:02 AM



Theme © iAndrew 2016 - Forum software by © MyBB