iWire has asked for the wisdom of the Perl Monks concerning the following question:

I have just transferred a site over to a new server. The perl scripts were working just fine on the old server and now it seems to be having issues and outputting the header content to the screen.

When I fill out a login form that gets send to the script (below) I receive the following error:

------------------------ Set-Cookie: loggedin=confirmed; path=/; expires=Mon, 07-Dec-2009 07:56 +:19 GMT Date: Mon, 07 Dec 2009 07:46:19 GMT Refresh: 1, https://www.m +ydomain.com/EAM/cgi-bin/admin/messageadmin.pl?action=list Content-Typ +e: text/html; charset=ISO-8859-1 ------------------------
Below is the code for the script
START CODE ------------------------ use CGI; $q = new CGI; if (!$q->cookie('loggedin')) { if ($q->param('username') eq "XXXX" && $q->param('password') eq "XXX +X") { if ($q->param('action') && $q->param('id')) { $action = $q->param('action'); $id = $q->param('id'); $cookie = $q->cookie(-name => 'loggedin', -value => 'confirmed', + -expires => '+10m'); print $q->header(-cookie => [$cookie], -refresh => "1, https://w +ww.mydomain.com/EAM/cgi-bin/admin/messageadmin.pl?action=$action&id=$ +id"); } elsif ($q->param('action')) { $action = $q->param('action'); $cookie = $q->cookie(-name => 'loggedin', -value => 'confirmed', + -expires => '+10m'); print $q->header(-cookie => [$cookie], -refresh => "1, https://w +ww.mydomain.com/EAM/cgi-bin/admin/messageadmin.pl?action=$action"); } else { $cookie = $q->cookie(-name => 'loggedin', -value => 'confirmed', + -expires => '+10m'); print $q->header(-cookie => $cookie, -refresh => '1, https://www +.mydomain.com/EAM/cgi-bin/admin/messageadmin.pl?action=list'); } } } else { print $q->redirect('https://www.mydomain.com/EAM/cgi-bin/admin/messa +geadmin.pl'); } END CODE------------------------

I'm in a real bind and I have no perl experience. Any help would be greatly appreciated.

Many thanks
Lee

Replies are listed 'Best First'.
Re: Outputs Headers after server change
by AnomalousMonk (Archbishop) on Dec 07, 2009 at 12:01 UTC

    I don't know the answer to your question, but I can tell you that you can do yourself an enormous favor by reading Markup in the Monastery (and related nodes), and then going back and updating your original post by removing all the  <br> tags and then wrapping your code (and output) in  <code> ... </code> or  <c> ... </c> tags. That way, something like  [$cookie] looks like  [$cookie] and not like the $cookie link. (Also, some indentation wouldn't hurt.)

    It's clear that, unlike some, you've put a good deal of effort into you post. It's a shame to see that effort misdirected.

Re: Outputs Headers after server change
by Anonymous Monk on Dec 07, 2009 at 13:00 UTC
    It looks like you're printing headers twice. If the beginning of your script is what you've shown, then your webserver is misconfigured.

    See CGI Help Guide

      Do you know what would be misconfigured to cause this issue?

        Please provide information on what the "old server" was and what the "new server" is. It is rather difficult to speculate otherwise.