develooper Front page | perl.beginners | Postings from January 2002

Re: What's wrong with this?

From:
Eduardo Cancino
Date:
January 24, 2002 14:07
Subject:
Re: What's wrong with this?
Message ID:
001901c1a4e8$d0c6ec30$200110ac@eduardo
Thank you everybody, now is working...


Japhy, may i call u that way?, in this part...

# inicia variables.
> >$to = "info\@domain.mx";
> >$from = "info\@domain.mx";
> >$subject = "Comentarios Sitio Web";
> >
> ># manda el mail.
> >open (MAIL,"|mail $to");
> >print MAIL <<"END_top";
> >
> >"To: $to
> >Reply-To: $to:
> >Subject: $subject"
> >
> >END_top
>
> That's not working, I can promise you that.

....the mail is being received.

With CGI.pm can I do this a lot easier???

How could I use de CGI.pm, there is a tutorial or something I can read about
it???
I don't understand how to use de CPAN. Can you give me any pointers???

Thanks everybody...

Lalo.










----- Original Message -----
From: "Jeff 'japhy' Pinyan" <jeffp@crusoe.net>
To: "Eduardo Cancino" <lalo@ciceana.org.mx>
Cc: <beginners@perl.org>
Sent: Thursday, January 24, 2002 10:39 PM
Subject: Re: What's wrong with this?


> On Jan 24, Eduardo Cancino said:
>
> >The next script runs looks pefectly in IE but in Netscape it shows the
> >source of the html...
>
> That is because IE does things that a browser should not do.
>
> ># recibe la forma.
> >read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
> >@pairs = split(/&/, $buffer);
>
> Ugh.  You should not try to deal with incoming form information yourself
> -- use the standard CGI.pm module.  Please.
>
> ># inicia variables.
> >$to = "info\@domain.mx";
> >$from = "info\@domain.mx";
> >$subject = "Comentarios Sitio Web";
> >
> ># manda el mail.
> >open (MAIL,"|mail $to");
> >print MAIL <<"END_top";
> >
> >"To: $to
> >Reply-To: $to:
> >Subject: $subject"
> >
> >END_top
>
> That's not working, I can promise you that.
>
>   print MAIL << "END_top";
>   To: $to
>   Reply-To: $to
>   Subject: $subject
>
>   END_top
>
> Notice I didn't quote the surrounding text.
>
> >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;
> >
> >   if ($form{$name} ne "" && $form{$name} ne "no" && $name ne 'enviar') {
> >      print MAIL $name . " = ". $form{$name} . "\n";
> >  }
> >}
>
> This is bad too.  Use CGI.pm.  Please.
>
> >
> >close MAIL;
> >
> ># imprime html.
> >print <<WEB_page;
> >
> >Content-type: text/html
> ><!doctype html public "-//w3c//dtd html 3.2 final//en">
>
> Here's the primary problem.  You cannot place a newline before the HTTP
> headers, and you MUST place an extra newline AFTER the HTTP headers.
>
>   print << "WEB_page";
>   Content-type: text/html
>
>   <!doctype ...>
>   ...
>   WEB_page
>
> Notice the difference?
>
> --
> Jeff "japhy" Pinyan      japhy@pobox.com      http://www.pobox.com/~japhy/
> RPI Acacia brother #734   http://www.perlmonks.org/   http://www.cpan.org/
> ** Look for "Regular Expressions in Perl" published by Manning, in 2002 **
> <stu> what does y/// stand for?  <tenderpuss> why, yansliterate of course.




nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About