This line:
do_redirect ( empty ( $STARTVIEW ) ? "month.php" : "$STARTVIEW.php" );
looks like it's trying to output a "Location" HTTP-header (code 301 - redirect maybe? i dont remember). Since you have HTML already outputted, you can't re-output headers.
If you don't know how HTTP headers work, I'd suggest not using them. Stick with a META tag, like so:
echo '<meta http-equiv="Refresh" content="0; URL=' . (empty($STARTVIEW) ? "month.php" : "$STARTVIEW.php") . "\">\n";
The alternate method is to store all the HTML output inside the PHP script, and only output it if the correct conditions are met (i.e. no Redirect headers need to be sent). Or, an even different approach still, would be to use output buffering (i.e. [man]ob_start/man ).
Up to you to decide how you want to rework this.