You need a webserver (OS X comes with Apache) which can run a program (Apache supports a number of options for running programs including CGI, FastCGI, and mod_php) that can make queries to the database based on the submitted form data.
http://www.cs.tut.fi/~jkorpela/forms/ is a good introduction.