Good Day, I have a question with regards to the message I received in the web browser. I have read that this 302 message is normal.
Status: 302 Found Location: http//192.168.1.5/train/main.htm
How can I get the page main.htm to load properly without receiving the message? I am a new programmer to Perl but enjoy reading about the workings of the language and truly enjoy learning Perl. I have to admit I am stumped.
What I have is a form, when submitted to a perl script, grabs the form values, connects to a sqlite3 db, checks for existing values,returns an html page. I realize the code needs work, but why won't the html page get processed? Instead I receive the Status: 302 message. I appreciate on the gentle help that could be available. Thank you!
#!/usr/bin/perl -wT
use CGI qw(:standard);
use CGI::Carp qw(warningsToBrowser fatalsToBrowser);
use strict;
use DBI;
print header;
print start_html("Login");
print h4("Login Engineer Form");
our ($p,$l,$a,$z,$id,$user,$password,$role,$query);
$query = new CGI;
foreach my $p (param()) {
$l = param('fname');
$a = param('userpassword');
$z = param('selectrole');
}
my $dbh = DBI->connect(
"dbi:SQLite:dbname=master_train.db",
{ RaiseError => 1 }
) or die $DBI::errstr;
my $sth = $dbh->prepare( "SELECT * FROM users" );
$sth->execute();
while(($id, $user, $password, $role)=$sth->fetchrow_array){
our ($l,$a,$z);
if(($l eq $user)&&($a eq $password)&&($z eq $role)){
if($role eq $z){
print redirect("http//192.168.1.5/train/main.htm")
+;
}
else
{
print redirect("http://192.168.1.5/train/login
+.htm");
}
}
}
$dbh->disconnect();
print end_html;
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.