fixed bugs/refactored

1. fixed a bug that threw an error when logging in. initialized
$_POST['search_field'] to null
2. more refactoring
code clean up
changed connection variable to global variables

deleting old file