php code made secure

#Modification:
1. application does not break if any credentials not sent
2. db parameters defined at the top, #todo: need to move it to one config file
3. Code indentations and `psr-2` coding standard implemented