Well as we are all interested in cutting out redundant code of any kind, there is a little simple script out there that can greatly assist in this. It's called the Echelon SQL Scripter (http://www.digitalthought.com/echelon/).
The PHP version supports both MySQL & PostgreSQL. Very simply, you:
1.) create your html forms (name your form element names the same as your column names in your database)
2.) point the form action to echelon.php and pass a url to redirect to
And that's it! Echelon will build the sql script on the fly, connect to the database & insert/update or delete data accordingly.
It has a built in debugger for trouble shooting as well.