PHP function to write in db. Has to be finished.