Do you mean instantly, or after a person clicks "Submit" on a form? If you're talking about instantly doing something then you'll need to look into using Javascript.
As for the updating the database part, that's easy - just use an UPDATE query (assuming you're using MySQL - you do realize you never even told us what database you're using) with the PHP function [man]mysql_query/man.