[prev in list] [next in list] [prev in thread] [next in thread] 

List:       cgi-list
Subject:    [CGI] nph - and redirection
From:       "Thomas Butler" <tommy () stealthaccess ! net>
Date:       2000-09-27 8:05:16
[Download RAW message or body]

What's the "Content-type: ..." for non-parsed headers?

I'm trying to redirect from a perl script with this line:
print "Location: http://www.tommybutler.com/guestbook.html\n\n;

and it doesn't work after having added the following line...
print "Content-type:text/html\n\n";

...to the top of my script because I was getting an error:
[Wed Sep 27 04:49:10 2000] [error] [client 64.24.142.163] malformed header
from script. Bad header=No comments were submitted to :
/data/domains/tommybutler.com/cgi-bin/guestbk.cgi

I need to redirect my users to the guestbook page, but my program is
printing out a page that says "Location:
http://www.tommybutler.com/guestbook.html" instead.  I know I need to send
new headers to the client specifying that the following command is a
locational directive instead of text/html, but I don't know how to do that.
Can anyone help me?

Here's the script source:
#!/usr/bin/perl
print "Content-type:text/html\n\n";
# Set Variables
$guestbook = "/data/domains/tommybutler.com/public_html/guestbook.html";
# parse input
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;
$FORM{$name} = $value;
}
# make newlines into html <br>'s
if ($FORM{"comments"}) { $FORM{"comments"} =~ s/(\r?\n)/\<br\>$1/gs; }
# return an error if no comments were passed
else { print "No comments were submitted to the program"; exit; }
# return an error if no name was passed
unless ($FORM{"realname"}) { print "No name was give to the program";
exit; }
# read guestbook.html
open (FILE,"$guestbook") or die "Can't Open $guestbook: $!\n";
@content = <FILE>;
close(FILE);
# write to guestbook.html
open (GUESTBK,">$guestbook") or die "Can't Open $guestbook: $!\n";
foreach $line(@content) {
if ($line =~ m/<!--begin-->/) {
$line .= "$FORM{'comments'}<br>\n";
$line .= "<blockquote><div div style='border-width: 1; border-style: solid;
border-color: #637BAD; padding: 8px;''>";
$line .= "<b>$FORM{'realname'}</b>";
$line .= "<br><a href='$FORM{'email'}'>$FORM{'email'}</a>" if
($FORM{'email'});
$line .= "<br>$FORM{'city'}" if ($FORM{'city'});
$line .= ", $FORM{'state'}" if ($FORM{'state'});
$line .= "<br>$FORM{'country'}" if ($FORM{'country'});
$line .= "<br><a href='$FORM{'url'}' target='blank'>$FORM{'url'}</a>" if
($FORM{'url'});
$line .= "</blockquote></div><hr><br>\n";
}
}
print GUESTBK @content;
close (GUESTBK);
print "Location: http://www.tommybutler.com/guestbook.html\n\n";
exit;

Thomas Butler
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Team leader, Apex Web Design Studios (c)  -new company name.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
http://TommyButler.com
        webdesign@tommybutler.com
                tel   8 1 7 . 4 6 8 . 7 7 1 6
                        fax   6 5 1 . 8 4 6 . 5 3 1 5
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Website design, E business solutions.


-----------------------------------------------------------------
To unsubscribe, send mail to "majordomo@jann.com" with "unsubscribe cgi-list"
in the body.

CalendarPlus v3.0 with JavaPlus is available NOW!
http://www.calendarplus.com/

The CGI Tips & Tricks website (and archive of the list) is located
at http://perl.jann.com/
-----------------------------------------------------------------

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic