//Stores the filename as it was on the client computer.
    $imagename = $_FILES['avatar']['name'];
    //Stores the filetype e.g image/jpeg
    $imagetype = $_FILES['avatar']['type'];
    //Stores any error codes from the upload.
    $imageerror = $_FILES['avatar']['error'];
    //Stores the tempname as it is given by the host when uploaded.
    $imagetemp = $_FILES['avatar']['tmp_name'];
    //The path you wish to upload the image to
    $imagePath = "/WebBristol/images/avatar/";
    if (is_uploaded_file($imagetemp)) {
        if (!move_uploaded_file($imagetemp, $imagePath . $imagename)) {
            $_SESSION['message']['warning'] = "Failed to move your image.";
        } else {
            $user->setAvatar($imagename);
        }
    } else {
        $_SESSION['message']['warning'] = "Failed to upload your image.";
    }
}
$user->setRole(1);
$idInserted = UserDAL::flush($user);
if ($idInserted > 0) {
    $action = empty($id) ? 'added' : 'edited';
    $_SESSION['message']['success'] = "Student {$action} with success!";
    header("Location: see/{$idInserted}");
} else {
    $_SESSION['message']['danger'] = 'Insert failed.';
    $redirect = empty($id) ? 'add' : "edit/{$id}";
    header('Location: ' . $redirect);
}