This is (or at least should be) a server-side task. You should re-post your question in the section specific to the server-side language you'll be using to create the login system.
You'll want to ask how to send the Location header in whatever language you choose ...
I suppose you could alternatively write some JavaScript on the page for a failed login. My JavaScript is a little rusty, but I think the following is a valid JavaScript redirect ... (on a 5 second timeout)
<script type='text/javascript'>
var redirect = setTimeout("window.location='http://google.com'", 5000);
</script>