Very Respected Revealers of Wisdom (and Tricks),
In the following script for password protecting a page (just a light password protect) that will then shoot the visitor through to another page (myview.cgi, which is in the same directory as this script), the redirect will not work. The redirect instructions get printed out to the display screen, they do not end up in the browser as the new URL. You'll see that I have not included a
$query->new_HTML line in order to try to remedy the problem. Still doesn't work. Any monk eyes out there to spot the problem?
#!/usr/bin/perl
use CGI;
$query = new CGI;
print $query->header;
print $query->start_form;
print "Enter the password: ",$query->textfield('pass',$default_name,10
+),"\n";
&submit_parameters($query) if $query->param('action') eq
+'Submit';
print $query->submit('action','Submit');
print $query->end_form;
sub submit_parameters {
local($query) = @_;
local($filename) = &check_name($query->param('pass'));
if($filename) {
print $query->redirect(-target => 'ResultWindow', -expires
+ => 'now',
-uri=>'http://lauragarcia.wso.net/CGI/mySQLeditor/myview.cgi');
}
}
sub check_name {
$password="muppets";
local($name) = @_;
unless ($name eq $password) {
print "<P>Try it again!";
return;
}
return "$name";
}
Eternally grateful!
laura.guimauve
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.