How do I call a program and hand it arguments when a post event occurs?

In keeping with the KISS principal, minimalism, I’ve got some powerful server side code I’d like to bring to bear on user input in an efficient manner and this question is about how to “release the hounds!” at an efficient moment – that is, when a user has performed a post.

A question I am NOT asking now regarding what I’d like to be doing is have keyword=value pairs derived from a form put into a file, then tell some purely not-web-server-related code to act on that data when the user has posted it. However, that’s for another post. For now, I’ve got a rather simplistic start based on, roughly, this example, as my strongest (but not very strong) web-front-end skills are in PHP and JS / HTTP/CSS – VASTLY stronger in the database-world!

Eventually I’ll do this in a more comprehensive form of keyword/value pairs in a file unique to each user interaction, in which case I’d like to hand the called code a unique file name to this ready-to-respond server-side program, I just don’t know how to tell it it’s time, or hand it the argument of the unique filename.

I’m sure I can get this to work with some clumsy tail -f type affair if it’s one file I know the name of, but I’m thinking there MUST be an easier / better way!

To clarify: How do I call an outside program upon a post event and hand it what one might think of as “command line arguments” such as a filename?