Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
Despite researching this via Perldoc, the web, and my Perl texts over several days, I remain stumped. My simple objective is to successfully execute the CGI script identified by the form action="...." parameter when the form is embedded in an email (in lieu of the more usual HTML file. I OBSERVE THAT THE FOLLOWING HTML FILE:
<html><head><title>Form data originating from HTML</title></head> <body> <form action="http://www.gmacfadden.com/cgi-bin/view_sent_form_data.cg +i" method="POST"> Your Subject: <input type="text" name="subject"><br> Your Comments: <textarea name="comments" rows="2" cols="15"></textarea +><br> <input type="submit" value="Send"> </form> </body> </html>
WORKS PERFECTLY WITH THE FOLLOWING PERL SCRIPT (LET'S CALL IT PERL SCRIPT #1)located at http://www.gmacfadden.com/cgi-bin/view_sent_form_data.cgi:
#!/usr/bin/perl -wT use CGI qw(:standard); use CGI::Carp qw(warningsToBrowser fatalsToBrowser); use strict; print header; print start_html("View data from form executed in HTML email"); my $subject = param("subject"); my $comments = param("comments"); print "\$subject is $subject<br>\n"; print "\$content is $comments<br>\n"; print end_html;
THE CRUX OF MY QUESTION IS WHY DOES PERL SCRIPT #1 FAIL TO PROVIDE THE SAME EXPECTED RESULTS WHEN I EXECUTE THE FORM FROM WITHIN AN EMAIL (USING THE SAME INPUT DATA AND THE SAME EMBEDDED FORM AS IN THE HTML FILE)AS CREATED USING THE FOLLOWING PERL SCRIPT (LET'S CALL IT PERL SCRIPT #2)?
#!/usr/bin/perl -wT use CGI qw(:standard); use CGI::Carp qw(warningsToBrowser fatalsToBrowser); use strict; my $torecipients = "gmacfadden\@aol.com"; #substitur your email addre +ss here my $header1 = qq (Mime-Version:1.0); my $header2 = qq (Content-type: text/html; charset="iso-8859-1"); my $content = qq( <html><body><center> <form enctype="multipart/form-data" action="http://www.gmacfadden.com/ +cgi-bin//view_sent_form_data.cgi" method="POST"><br> Subject: <input type="text" name="subject"><br> Comments: <textarea name="content" rows="2" cols="15"></textarea><br> <input type="submit" value="Send"> </form></center></body></html> ); print header; print start_html("Create form within HTML E-Mail"); $ENV{PATH} = "/usr/sbin"; open (MAIL, "|/usr/sbin/sendmail -oi -t") or &dienice("Can't fork for sendmail: $!\n"); print MAIL "$header1\n"; print MAIL "$header2\n"; print MAIL "To: $torecipients\n"; print MAIL "From: anybody\@anywhere.org\n"; print MAIL "Subject: Please complete the enclosed form\n\n"; print MAIL "$content\n"; close(MAIL); print <<EndHTML; <h2>The requested form data has been embedded in an email sent to you! + Thank you</h2> EndHTML print end_html; sub dienice # The dienice subroutine handles errors. { my($errmsg) = @_; print "<h2>Error</h2>\n"; print "<p>$errmsg</p>\n"; print end_html; exit; }

In reply to passing CGI form parameters via HTML email by gmacfadden

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (7)
As of 2023-12-06 18:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What's your preferred 'use VERSION' for new CPAN modules in 2023?











    Results (31 votes). Check out past polls.

    Notices?