SQL and php code added for databases