If you're planning on writing your own, learning to use and implementing
Akismet is without a doubt the best way I've encountered to virtually eliminate the automated spam posts and such. If you've used Wordpress.com that's what they've got (for me it will often catch hundreds of spam posts a month).
There's an API and documentation at
http://akismet.com/development/
So, with that in mind, if you're using PHP, it's fairly easy. Take a look at
http://www.w3schools.com/html/html_forms.asp for the HTML side that gives the form and on the PHP side, variables are automatically put in $_REQUEST['name']; where 'name' is whatever you called them on the form. Then you use whatever database/file method you want to store/retrieve and present them.
http://www.w3schools.com/php/php_forms.asp has some PHP form samples (and, if you're using something other than PHP, you can look around on W3schools for that language, they have examples for several different possibilities)