Lost has asked for the wisdom of the Perl Monks concerning the following question:

I posted a question earlier, but the suggestions (and I DO appreciate them) still don't work. Let me re-explain:
I recently switched a client from a single pagefront web site to a frameset design; (please no lectures, it gives my client the presentation he wants). Since then, his "Contact Us" form has not worked properly. I parse the user input with the following script. Now, the script is executed, but the email he receives has no user entered text. Again, I have run it through my trusty copy of Perl Edit, and it says the syntax is perfect; no errors are generated. But, when I run it through his web host's Perl checker (Yahoo! Small Business) it generates the dreaded error:"Use of uninitialized value in concatenation...at lines 34-46"; (which would be the info requested to be sent in the email request). The following script was working perfectly before, and I guarantee I haven't touched my script prior to it not working. I re-checked my name/value pairs and they match up fine. I'm assuming I may have inadvertantly messed up something in Sendmail; (i have rechecked the sendmail path and it matches up fine) and I'm sure it was something basic as it executes the script, the "Request Received" receipt for the user comes up after they press the "Submit Button" and my client receives the request in his email box; but with none of the user entered text....ARRGH.

#!/usr/bin/perl -w use strict; use warnings; use CGI; my $query = new CGI; print "Content-type:text/html\n\n"; my $to='info@clients URL'; my $from='info@clients URL'; my $subject='Web Site Design Request'; my $name = $query->param('name'); my $email = $query->param('email'); my $address1 = $query->param('address1'); my $address2 = $query->param('address2'); my $city = $query->param('city'); my $state = $query->param('state'); my $zip = $query->param('zip'); my $country = $query->param('country'); my $homephone = $query->param('homephone'); my $workphone = $query->param('workphone'); my $business = $query->param('business'); my $goals = $query->param('goals'); my $comments = $query->param('comments'); open(MAIL, "|/usr/sbin/sendmail -t"); print MAIL "To: $to\n"; print MAIL "From: $from\n"; print MAIL "Subject: $subject\n\n"; print MAIL "Name: $name\n"; print MAIL "EMail: $email\n"; print MAIL "Address_line_1: $address1\n"; print MAIL "Address_line_2: $address2\n"; print MAIL "City: $city\n"; print MAIL "State: $state\n"; print MAIL "Zip: $zip\n"; print MAIL "Country: $country\n"; print MAIL "Home_Phone: $homephone\n"; print MAIL "Work_Phone: $workphone\n"; print MAIL "Type_of_Business: $business\n"; print MAIL "Goals: $goals\n"; print MAIL "Comments: $comments\n"; close(MAIL); print "<html><head><title>Clients URL title/title> <link href=http://clients css/css/shell3.css rel=stylesheet type=text/ +css> </head>\n<body>\n"; print "<HR size=2>"; print "<CENTER><H1><U>Message Received!!!</U><P> YOUR business is VERY important to us<P> <U>We will respond as soon as we can.</U></H1></CENTER>"; print "<P>"; print "<center><a href=http://clients URL/index.html><I>Clients URL</I +> Home Page</a></center>"; print "<hr size=2>"; print "</body></html>";

Replies are listed 'Best First'.
Re: Hand Rolled CGI/Sendmail
by sgifford (Prior) on May 07, 2004 at 19:28 UTC

    Can you print the information you get from the user? That should tell you whether the problem is the email, or getting the data from the user.

    Also, checking for a failure of new CGI and the open and close of MAIL might tell you what's going wrong.

      I can't print any of the info obtained from the user. The HTML form accepts the input, the "Submit" button works, an email is sent to my clients Inbox, but when the email is open, the field titles (i.e.-Name:, Address:, etc) are there but none of the text the user inputs into the text fields are printed into the email.
      Can you refresh me on how to check for failure of the Open,Close, and new CGI
        You can't print user input to either the mail message or in the response HTML page? Are you sure you're getting the information, then? Try printing $query->Dump somewhere and see if the CGI object has in it what you expect.

        As for error checking, using or die "error..." should do the trick:

        my $query = new CGI or die "Couldn't create CGI object!\n"; open(MAIL, "|/usr/sbin/sendmail -t") or die "Couldn't start sendmail: $!\n"; close(MAIL) or die "Error closing sendmail: $!, exit status $?\n";