rewrote login php

simplified the code and fixed a bug