In your "else" clause, instead of creating another form ("click here to continue", etc.), just issue a redirect (which goes to the same place your button-click takes you.)
However - there's a big problem with the way you're doing this - you're not storing the login state into a session variable. Since HTML is stateless, once someone moves past your login page, you'll have no way of remembering whether they're logged in or not. If you don't store that state somewhere, and check it on every page, then people can leap-frog your login page and get to any page they want.
Here's a link to a simple login tutorial I wrote:
RFC: Proposed tutorial - simple login script using CGI::Application
That should help get you started.