Thanks in advance for any help. -Ken#!/usr/bin/perl -w use CGI qw(:standard); use CGI::Carp qw/fatalsToBrowser warningsToBrowser/; #fatalsToBrowser(1); use DBI; use strict; use Data::Dump qw(dump); my $q = CGI->new(); print $q->header(-cache_control=>"no-cache, no-store, must-revalidate" +); print <<BodyHTML; <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http:/ +/ www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd "> <html lang="en" xml:lang="en" xmlns=" http://www.w3.org/1999/xhtml"> <head> <title>Login Page</title> </head> <body> <form name = "login" action = "loginpage.cgi " method = "GET"> <table> <tr> <td> User Name<br />(25 characters or less) </td> <td> Password<br />(8 - 15 alphanumeric characters) </td> </tr> <tr> <td><input type = "text" name = "UserName" id = "UserName" size = "25" maxlength = "25" tabindex = "0" /> </td> <td><input type = "text" name = "Password" id = "Password" size = "15" maxlength = "15" tabindex = "1" /> </tr> <tr> <td> <input type = "submit" value = "Login" tabindex = "2" /> </td> </tr> <tr> </tr> </table> </form> BodyHTML my ($DBserver, $DBdatabase, $DBuser, $DBpassword) = ('LOCALHOST','test +db','kbuttler','gghy'); my $dbh = DBI->connect("DBI:Sybase:server=$DBserver;database=$DBdataba +se",$DBuser,$DBpassword) or die "Can't connect to Sybase database: $DBI::errstr\n"; my $usernamequery = param("UserName"); my $username_q = $dbh->quote($usernamequery); my $passwordquery = (param("Password")); my $password_q = $dbh->quote($passwordquery); my $sth1 = $dbh->prepare("select username from logintable where userna +me = $username_q "); $sth1->execute(); my $row1 = $sth1->fetchrow_arrayref(); if ( $row1->[0] eq $usernamequery ) { my $sth2 = $dbh->prepare("select password from logintable where pa +ssword = $password_q "); $sth2->execute(); my $row2 = $sth2->fetchrow_arrayref(); $sth2->finish(); if ( $row2->[0] eq $passwordquery ) { print $q->redirect("http://localhost/cgi-bin/librarian.c +gi"); } else { &dienice(qq(The password is invalid.)); exit; } } else { &dienice(qq(Username does not exist.)); exit; } $sth1->finish(); $dbh->disconnect; print end_html; sub dienice { my ($msg) = @_; print "<h1>$msg</h1>"; exit; }
In reply to how to move to new page on successful login by arnieboy
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |