This seems to be requested quite often.
AJAX is the short answer. But beware, you will need some PHP knowledge at least. Cause writing to database or flatfile would be done with PHP (at least I can't think of a different way to do it currently).
An easier local solution can be achieved with Web Storage, saving data in the browser.