Button Onclick To Save Some Data On Db

Hi, i’m new to yii and still on a testing mode.

can someone please tell me on how to create an image button that "onclick" will allow me to save a users current id on the database. Do i use ajax? if so how? is there a better way to solve this?

any help is appreciated.