Attempting to build template but Having Issue with gets and posts
Well a more elegant approach would be to use an MVC pattern as a starter framework I would suggest you to use Laravel it's very clear written and also an easy catch for people who are general new to MVC. The way your currently writing the code, you include to much business logic inside of it. 

Which in the long term is terrible because the code becomes un-maintainable, for that the MVC Pattern is the best way to write clear and maintainable code, but check it out yourself. An good article to start with should be this one by Nettuts, called MVC for Noobs don't get irritated by the name the article is pretty good and should get you a basic understanding of the MVC pattern.

Hope I could be a little help :)