2010年2月10日水曜日

perl tips

$querry = new CGI;
$user_id = $querry->param("user_id");
$user_pass = $querry->param("user_pass");

$dbh = DBI->connect("DBI:Pg:dbname=$dbname", "$dbusername", "$dbpassword");
$sql = "select count(*) from auth_tbl where user_id = ? and user_password = ?";
$sth = $dbh->prepare($sql) or die "can not execute: ". $sth->errstr();
$sth->execute($user_id, $user_pass) or die "Cannot execute: ".$sth->errstr();

@row;
@row = $sth->fetchrow_array();

$cnt = $row[0];
if ($cnt == 1) {
$auth_flg = "true";
}

$sth->finish();
if( $auth_flg ne "true") {
print $querry->redirect("/aaa.html");
} else {
print $querry->redirect("/bbb.cgi");
}

0 件のコメント: