newbie430 has asked for the wisdom of the Perl Monks concerning the following question:
I am trying to create a session for my web application using Dancer2. I currently using mysql database. I searched alot of reference on the internet because I'm new to Perl it seem the references are too complicated. Please guide me. Here is my .pm code.
post '/' => sub { my $username = $q->param("username"); my $password = $q->param("password"); my $loginstatement = 'SELECT * FROM account WHERE username=? a +nd password=?'; my $sth = $dbh->prepare($loginstatement) or die $dbh->errstr; $sth->execute(params->{'username'}, params->{'password'}) or d +ie $sth->errstr; my (@userID) = $sth->fetchrow_array; if ($userID[0] != 0 && $userID[11] ==1 ){ my $sessionstatement = "SELECT * FROM sessions"; my $sth2 = $dbh->prepare($sessionstatement) or die $db +h ->errstr; my (@sessID)= $sth2->fetchrow_array; if($userID[3] == $sessID[1]) { session 'logged_in' => true; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: session with mysql database.
by Anonymous Monk on Apr 14, 2015 at 08:59 UTC | |
by Anonymous Monk on Apr 14, 2015 at 09:08 UTC | |
|
Re: session with mysql database.
by locked_user sundialsvc4 (Abbot) on Apr 15, 2015 at 14:16 UTC |