Redirect from one CGI page to another

I am a nembie for CGI with Perl, please help me and please correct me wherever I make a mistake.

This is the code. The problem is that after the password is verified and found to be correct, instead of redirecting to the next page, it will send the following message:

Status: 302 Found Location: http://localhost/cgi-bin/Main.cgi 

 #!C:\perl\bin\perl.exe use CGI qw(:standard); use CGI::Carp qw(fatalsToBrowser); use DBI; use strict; use DBI; use strict; use warnings; my $q = new CGI; print "Content-Type: text/html\n\n"; if ($q->param("Login")) { my $Password = param('Password'); if (!$Password) { print "Please Enter the Password"; } else { my $dbh = DBI->connect( "dbi:SQLite:DEVICE.db", "", "", { RaiseError => 1, AutoCommit => 1 } ); my $sth = $dbh->prepare("select * from Settings where Password = ?"); $sth->execute($Password); if (my $pass = $sth->fetchrow_hashref) { print redirect(-url => 'http://localhost/cgi-bin/Main.cgi'); } else { print "Invalid Password"; display_form(); } $dbh->disconnect; } } if (($q->param("submit"))) { process_form(); } else { display_form(); } sub process_form { if (validate_form()) { } } sub validate_form { my $User_Password = $q->param("Password"); my $error_message = ""; $error_message .= "Please enter the Password<br/>" if (!$User_Password); if ($error_message) { display_form($error_message, $User_Password); return 0; } } sub display_form { my $error_message = shift; print <<END_HTML; <html> <head><title>Form Validation</title></head> <body> <form method="post"> <input type="hidden" name="submit" value="Submit"> <TABLE align="center" bgcolor=#B0C4DE> <TR> <TD> Enter The Password And Click Login</TD> </TR> <TR></TR> <TR></TR> <TR></TR> <TR></TR> <TR></TR> <TR> <TD><b>PASSWORD</b> : <input type="password" name="Password" size="20" maxlength="15" /></TD> </TR> <TR></TR> <TR></TR> <TR></TR> <TR></TR> <TR></TR> <TR> <TD align="center" colspan="2"> <input type="submit" name="Login" value="Login"> <input type="reset" name="Cancel" value="Cancel"> </TD> </TR> </TABLE </form> </body> </html> END_HTML } 
0
sql perl sql-server-2005 cgi
source share

No one has answered this question yet.

See similar questions:

6
How to redirect a client from one CGI page to another using Perl?

or similar:

3491
How can I UPDATE from SELECT in SQL Server?
1787
How to concatenate text from several lines to one text line on SQL server?
1658
How to return only date from SQL Server DateTime data type
960
Insert into ... values ​​(SELECT ... FROM ...)
874
Updating SQL from one table to another based on identifier
664
What is a common gateway interface (CGI)?
one
How to get CGI script response using AJAX
0
how to run perl script after clicking html onclick button
0
Browser does not respond / does not update perl CGI redirect / print html after enabling jquery-1.11.3.min.js
0
perl cgi :: param error with one plus sign in Taint mode

All Articles