
hwnd
User
Mar 31, 2011, 7:26 PM
Views: 14388
|
|
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:
#!/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)
|