Newbie Question: How do I get my site clicks to log to a database file?

I’ve made a site using Flash.

I want go back and set the site up so that each click on a button/movie clip gets logged to a database on my server.

What’s the easiest way to achieve this?