Hi.

Whenever I try to get the value of a field in a row from a SQL database, I'm
either passed a blank line or the name of the spot in memory in which the
information I want resides (like HASHx('80fd23afcc') or something).  Earlier
in the code, the right use statements as well as $Sql = TTMSSQL->new;.
TTMSSQL is a customized engine for generating SQL queries, if you need to
see the whole thing I can make it available.

emit_ and post_ routines are called via a RequestHandler when the user goes
to certain URI's on the server...  The RequestHandler and Dispatch Table
work just fine as I've thoroughly tested them..  This SQL is simply not
working tho >:|

Here are the routines.

sub get_password {
        my $state = shift;

        my $sth = $Sql->select_decode('PWORD', 'techs',
"TECH=\"$state->{q}->{login_user}\"
");
        my $row = $sth->fetchrow_hashref;

        return $row->{PWORD};
}

sub emit_login_form {
        my $state = shift;
        my %args = $state->{q};
        $state->{template} = 'generic.tmpl';
        $state->{title} = 'TTMS Login';

        $args{body} = <<EOF;
<form method="post" action="http://ttms.stout.dyndns.org/login.cgi";>
<table border-"0" cellpadding="0" cellspacing="0">
<tr><td>Username</td><td><input type="text" name="login_user"></td></tr>
<tr><td>Password</td><td><input type="password" name="login_pass"></td></tr>
<tr><td colspan="2" align="center"><input type="submit"
value="submit"></td></tr>
</table>
</form>
EOF

        return output_html($state, %args);
}

sub post_login_form {
        my $state = shift;
        my %args = $state->{q};
        $state->{template} = 'generic.tmpl';
        $state->{title} = 'TTMS Login';

        my $checkpass = get_password($state);

#       if ($checkpass eq $state->{q}{login_pass}) {
#               $state->{login_user} = $state->{q}{login_user};
#               $state->{login_pass} = $state->{q}{login_pass};
#               $state->{auth_status} = "Logged in as $state->{login_user}";
#               $state->{cookie_out} = set_auth_cookie($state);

#               $args{body} = "Login Successful!";
#       } else {
#               $state->{cookie_out} = set_logout_cookie($state);

#               $args{body} = "Login Unsuccessful.";
#       }

        $args{body} = "login_user: $state->{q}{login_user}<br>login_pass:
$state->{q}{login
_pass}<br>checkpass: $checkpass";
        return output_html($state, %args);
}

sub select_decode
{
        my $self = shift;
        my $dbh  = $self->{dbh};
        my($select,$from,$where,$other) = @_;

        my $sql="SELECT DECODE($select,\'blah\') ";
        $sql .= "FROM $from "   if $from;
        $sql .= "WHERE $where " if $where;
        $sql .= $other          if $other;

        # connect , or reuse $dbh, prepare and execute
        my_warn $sql;
        my $sth = $self->prepare($sql);

        $sth->execute                   or die "execute failed:
$DBI::errstr";

        $sth;
}

Thanks,
Dennis


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to