$sql = "UPDATE profile SET name = '".$name.'" WHERE userid = '".$_SESSION['userid].'"; $update = $connection->query($sql); if($update){ $_SESSION['name']=$name; }