Changed logincheck + added redirect

Simplified the loginchck en moved the redirect to its own function. A
redirect must alwas be an 3xx code, instead of a 4xx code, even if you
want to redirect away from the forbidden page.

Also added PHPDoc in fornt of the redirect function.