first of all, you should NEVER EVER use "echo" or "print" inside functions or methods, except if you temporarily want some output debugging. learn that the output of a function is always done with "return".
much more ugly is your method to mix up "pure" html with php code. (by using <?php $myContent = ""; ?><html><title><?php echo $myContent; ?></title> ... and so on.)
to separate code from html, you could put the html into a separate file, e.g. form.tpl and put placeholders (e.g. in the form {myPlaceHolder} ) at the position where php should put its output in.
on php-side, you load the form.tpl in with fopen, fread, fclose e.g. in a string variable $template. then create an array
$trans = array(
'{myPlaceHolder}' => "myPlaceHolderContent",
'{mySecondPlaceHolder}' => 'mySecondPlaceHolderContent',
);
and when you're done with that you replace the placeholders with the php-generated content.
return strtr($template,$trans);
by this, you separate html from php.