Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: How do I end a while loop early?

by ig (Vicar)
on May 08, 2013 at 07:57 UTC ( #1032587=note: print w/ replies, xml ) Need Help??


in reply to How do I end a while loop early?

I would try:

use DBI; use CGI qw /:standard/; use CGI::Cookie; use warnings; if (! defined $cookies{'authorized'}) { if (param) { my $username = param('username'); my $password = param('password'); my $dbh = DBI->connect("dbi:SQLite:dbname=/path/to/dat +abase.db","",""); my $sth = $dbh->prepare('select * from useers where username = ? and password = ?' +); $sth->execute($username,$password); my @row = $sth->fetch_array; if (@row) { #login success, set authorized cookie my $cookie = CGI::Cookie->new( -name=>'authorized', -value=>1, -path=>'/default/url'); } else { print_login_form(); exit; } } else { print_login_form(); exit; } } #once that specific cookie is set, i redirect print redirect('search.cgi'); exit; sub print_login_form { print header,start_html('Login'),h1('Login'), start_form, "Username: ",textfield('username'),br, "Password: ",password_field('password'),br, submit("Enter"); end_form, end_html; }


Comment on Re: How do I end a while loop early?
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1032587]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (10)
As of 2014-08-28 00:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (254 votes), past polls