Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

perl redirection not working 1

Status
Not open for further replies.

lily1

Programmer
Mar 13, 2004
17
US
I have a simple form, if the user enters a correct username and password, then the page will be redirect to a new page, but the result is the perl script print the code "Location: ' and does not redirect. The following is my script:
#!/usr/bin/perl

read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
@pairs = split(/&/, $buffer);

foreach $pair (@pairs) {
($name, $value) = split(/=/, $pair);

$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$name =~ tr/+/ /;
$name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;

$FORM{$name} = $value;
}


print "Content-type: text/html\n\n";
print "<HTML><HEAD>";
print "<TITLE>Confirm Login</TITLE>";
print "</HEAD>";
print "<BODY>";

if ($FORM{'Name'} eq "test" ){
if ($FORM{'Password'} eq "test" ){
print "Location: ' }
else{
print "The 'Password' is incorrect, please <a href='../medialogin.htm'> go back</a> and try again.";

}
}
else{
print "The 'Name' is incorrect, please <a href='../medialogin.htm'> go back</a> and try again.";


}


print "</BODY></HTML>"


Any suggestion would be appreciated.
 
It is because the print "Content-type: text/html\n\n"; is passed before the redirect.

Place the Content-type within your Condition but after the redirect.

M. Brooks
X Concepts LLC
 
use JavaScript...

<html>
<script language="javascript">
window.location="main.html"
</script>
<body>
</body>
<html>


Kind Regards
Duncan
 
Thanks for your kindly reply, the script works now.
 

Though, this is very helpful. I wonder if there is a way to do something (totally in perl)

print header;
...


(undo the header);

print redirect ( since this is consider header also ).

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top