Your logic needs to be reworked a bit. Look at this snippet:
if (isset($_SESSION['id'])) {
$id = $_SESSION['id'];
} else {
print "You are not logged in!!";
}
// Get Username
$sql= mysqli_query($myConnection, "SELECT * FROM members WHERE id = '$id'");
If they aren't logged in, that's fine - they'll get the "You are not logged in!!" message. But then the very next statement uses $id as if you never checked for it in the first place.
You should move those SQL queries so that they only process if the 'id' was set in the first place.
You should also find some basic tutorials on how to retrieve data from a SQL server. For example, this code:
// Get Username
$sql= mysqli_query($myConnection, "SELECT * FROM members WHERE id = '$id'");
while($row = mysqli_fetch_array($sql))
{
$username= $row['username'];
}
//Check if allowed
$sqlcheck= mysqli_query($myConnection, "SELECT * FROM members WHERE id= '$id' ");
while($row = mysqli_fetch_array($sqlcheck)){
$acc_type= $row["account_type"];
}
should really be written as:
// $id is assumed to be numeric *and* sanitized!
$sql= mysqli_query($myConnection, "SELECT id, username FROM members WHERE id = $id LIMIT 1");
if(mysqli_num_rows($sql))
list($acc_type, $username) = mysqli_fetch_assoc($sql);
else {
// error: no user found with corresponding id
}