[ back to toc ]

header method in CGI.pm

Date: 2002/01/13 10:05

Q:
I'm having a problem with the following snippet of code.

if($password eq $storedpassword)
{SetCookie();
$po = "orders/$po_id\.txt";
GetLastOrder();
WriteFile();
print "Location: http://$base/cgi-bin/orderUpdate.cgi\n\n";
}

When the script gets to the 'print "Location:', it prints on the screen
(as another line on the form). I've commented out "SetCookie()" (where
the 'header()' method is used) and everything works fine. Except, of
course, no cookie.

My thought was to reset the header via the 'header()' method. However I
can't find how to set the header to it's default. How is this done? or
alternately how do I get around the problem that setting a header in the
cookie causes the program to print to the screen?

I hope this is clear. My head is reeling from trying to find the answer
from my collection of Perl and CGI books. Thanks for your help.

*NAME-DELETED*

A:
if($password eq $storedpassword)
{print "Location: http://$base/cgi-bin/orderUpdate.cgi\n";
SetCookie();
$po = "orders/$po_id\.txt";
GetLastOrder();
WriteFile();
}

Regards,
Peter

[ back to toc ]