> So, what's going wrong here? Why is the PHP that I have added to the template been deleted when I apply the template to a page?
You may be getting caught in the fact that the region above <html> is regarded as an EDITABLE REGION by the template engine. In that case, editable region content is not propagated to child pages.
I have been doing exactly the same thing, but in reverse sortof. My approach is to create the DB pages, then create a NEW child page from the template, and copy/paste content from the existing DB pages into the new child pages. That way I can make sure that all of the important stuff gets into the right place. Of course this presupposes that you know what is the important stuff to copy and where to copy it!
We would probably have to see your page to tell you what to do about the file field validation issue - but generally, you'd click in the field (in Design view) then click on the Spry tab that appears on the screen (the CYAN one), and finally select the highlighted tag on the tag selector before clicking on the delete key. That gets rid of the Spry stuff around the file field - you'd still have to remove the corresponding Spry javascript variable definition at the bottom of the page's code to complete the job.
We'd definitely need to see your code for the other two issues.