Instead including php files in templates, better is create new module where you have full control on the input and the output. Data from your form you can pass to your module, then validate and do some action with them. You can of course use templates for output presentation from your module.
Good tutorial how to create new module you can find here: http://ez.no/products/ez_publish/documentation/development/extensions/module/hello_world