Updated php code to be more like Restful API