Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 1 Oct 2003 12:04:27 -0500
From:      "Charles Howse" <chowse@charter.net>
To:        <freebsd-questions@freebsd.org>
Subject:   Perl cgi redirect not working
Message-ID:  <005901c3883e$12780030$04fea8c0@moe>

next in thread | raw e-mail | index | archive | help
Hi,
I'm *copying an example* perl cgi script from "FreeBSD Unleashed" pp.
699.
I have 2 issues.

1. The redirect on the last line isn't working.  It opens a blank page
and prints the text "Location: http://howse.no-ip.org/thanks.shtml".
That's not what I want.  I want to open the page thanks.shtml.

2. I can't see the text in the book clear enough to know whether the
characters I've marked with ^ should be dashes or tildies.

I've Googled for the redirect, and tried a few examples, no joy.
Would someone be kind enough to help?


#!/usr/bin/perl

read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
@pairs =3D split(/&/, $buffer);
foreach $pair (@pairs)
{
    ($name, $value) =3D split(/=3D/, $pair);
    $value =3D~ tr/+/ /;
            ^
    $value =3D~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
            ^
    $value =3D~ s/~!/ ~!/g;
            ^   ^   ^=20
    $FORM{$name} =3D $value;
}

print "Content-type: text/html\n\n";

open (MAIL,"| /usr/sbin/sendmail -oi -t");
print MAIL "From: $FORM{'name'} <$FORM{'email'}>\n";
print MAIL "To: charles\n";
print MAIL "Subject: Contact form output\n\n";
print MAIL "$FORM{'name'}, from $ENV{'REMOTE_HOST'}
($ENV{'REMOTE_ADDR'}), has sent you the following comment:\n\n";
print MAIL "$FORM{'comment'}\n";
close (MAIL);

print "Location: http://howse.no-ip.org/thanks.shtml\n\n";



Thanks,
Charles

Got a computer with idle CPU time?
Join SETI@home and help make history!
http://setiathome.ssl.berkeley.edu/




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?005901c3883e$12780030$04fea8c0>