Small changes to php files

-Some code changes
-Changed error messages to alert dialogs