Added php to write to database