fixed code for recording login attempts
moved error email code from view to controller