added php part for sync with database