A quick thing i noticed. That might be the problem. The $_SESSION['userid']
is getting value from $userid
which is not set. Also using @
to supress your error is not a good practice. use isset
to check if the variable is set and continue.
$_SESSION['userid'] = $userid; //where are you getting $userid from?
This should be
$_SESSION['userid'] = $dbuserid;
Also instead of using statement like
if ($_SESSION['username'])
First check if the variable is set like this
if ( isset($_SESSION['username']) ){
//now continue your work
}