I need a form on a web site to write to a .csv or MySQL database

I have a form on a web site that sends the information collected to a email account. I want the information placed into a .csv file that I can access or in a my sql data base. Can someone point me in the right direction to get this accomplished?