Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 5 Oct 2003 13:50:20 -0500
From:      "Charles Howse" <chowse@charter.net>
To:        "'Nick Rogness'" <nick@rogness.net>
Cc:        freebsd-questions@freebsd.org
Subject:   RE: Perl cgi redirect not working
Message-ID:  <003a01c38b71$86d18830$04fea8c0@moe>
In-Reply-To: <20031005025435.U45148-100000@skywalker.rogness.net>

next in thread | previous in thread | raw e-mail | index | archive | 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;
> >             ^   ^   ^
> >     $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";
> >
>=20
> 1) This is a little extreme for a simple redirect.  A simple=20
> 3 liner will
>    do the trick:
>=20
>   #!/usr/bin/perl
>=20
>   print "Location: http://howse.no-ip.org/thanks.shtml\n\n";
>   exit;

Actually, this was a CGI script to respond to an email form on my
website.
When I posted asking the same question on a newsgroup, I was flamed so
severely for using "buggy, crappy" code that got busy, did some
research, and have moved 'up' to FormMail.pl, which is working perfectly
now.

The problem with the book code is that 'Content-type' line.
Removing it fixes that code.

>=20
> 2) They are suppose to be tildes (~).

Thank you for a respectful answer.  :-)




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?003a01c38b71$86d18830$04fea8c0>