CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: DBI: Re: [FishMonger] Is there a better way to write this to check login information?: Edit Log



hwnd
User

Mar 31, 2011, 7:26 PM


Views: 17264
Re: [FishMonger] Is there a better way to write this to check login information?

Possbily could you break this down how to implement this into how i would use this for this kind of job?

Here is my current updated code:


Code
#!/usr/bin/perl -T 

use strict;
use warnings;
use DBI;
use CGI;

my $q = CGI->new;

my $stored_user = $q->param('user');
my $stored_pass = $q->param('pass');

print $q->header;

my $dbh = DBI->connect("DBI:mysql:hwnd_news:localhost", "hwnd_hwnd", "b71lnk")
or die $DBI::errstr;

my $sth = $dbh->prepare("select id, name, pass from news_users WHERE name = ? AND pass = ? LIMIT 1");
$sth->execute($stored_user, $stored_pass);

my ( $id, $name, $pw ) = $sth->fetchrow_array();

if (($name eq $stored_user) && ($pw eq $stored_pass)) {
print "good login\n";
}
else {
print "bad login\n";
}



(This post was edited by hwnd on Apr 1, 2011, 4:21 AM)


Edit Log:
Post edited by hwnd (User) on Apr 1, 2011, 4:21 AM


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives