What is the best way to process a form in WP using correct design patterns? I am finding a lot of outdated and inconsistent information online and the way I am doing it now is not sustainable.
At the moment, when I am doing some heavy PHP work (ie.. processing large forms) I tend to create a page in WordPress, flesh out the HTML as much as I can and then create a custom template.. within the template I then add the form processing PHP stuff... this works well but duplicates a lot of template code and if it's a large site I end up with lots of custom templates.
Other solutions i've seen online:
create a function and then add it to the init filter, add a hidden form field in the html so that the form is specifically targeted.. this looks like it will try to process this request on each page load, so doesn't look like viable solution.
Create a plugin - as above, I don't really want to create a full new plugin just to process a form.
Create a separate PHP file called process and just stuck the PHP stuff in here, this seems like it removes itself from WP all together, i've actually seen some examples have this completely independent as it even has the mysql connect stuff in there.
[edit] Here is my form submission function: http://pastebin.com/VZCw3Br3 It's a bit of a mess so I have commented it as much as possible.