Wiggins d'Anconia wrote:
Phillip Bruce wrote:

Hi,

  I have the following form that I use as survey I that I'm
  building for my web site.

<snip form>



Now here is the CGI script I've written so far.


#!/usr/bin/perl # use Mail::Internet;


use strict; # always use warnings; # usually, at least during development

# Collect parameters using CGI
my $customer = param("Customer");
my $learn = param("Learn");
my $opinion = param("Site Opinion");
my $improvements = param("Site Iimprovement");
my $comments = param("comments");


In the above section you are using a function of the CGI module 'param' but you have not loaded the CGI module, you need another use statement:


use CGI;

You may also want to get all the params at once into a hash, but I leave that to you, have a look at the docs for the CGI module:

perldoc CGI

my $head = Mail::Header->new;


What does this do on failure? you haven't checked return codes...

$head->add(From => 'Webmaster <[EMAIL PROTECTED]>');
$head->add(To   => '[EMAIL PROTECTED]');
$head->add(Subject => 'hello there');

my $body = <<END;
This is just a simple e-mail message.
Nothing to get excited about.

Customer Type: $customer
How they learn of us: $learn
Their Opinions: $opinion
Their improvemetns: $improvements
Their comments: $comments
END

$mail = Mail::Internet->new(Header => $head,
                            Body   => [$body],
                            Modify => 1);
print $mail->send('sendmail');


You have not printed a header back to the browser, usually something like: Content-type:text/html\n\n, though again see the docs for the CGI module for easy ways to do this.


end of cgi script.

What I'm concern with is the execution of this script.
I don't seem to be doing something right. Can someone
correct on what it that missing.



Usually the best way to find out problems with a CGI script is to check the server's error log, or use a 'fatalstobrowser' type of deal, see the CGI docs for this also...

Thanks for the suggestions. Now I get totally different error. I ran this on the command line and get following:

% ./survey.cgi
Content-type: text/html

Substitution replacement not terminated at ./survey.cgi line 37.

Here is my code changes I've made:

#!/usr/local/bin/perl
use strict;
user warnings;
use CGI;
use Mail::Internet;

BEGIN {
  print "Content-type: text/html\n\n";
}  # So we can debug using the web

# Collect parameters using CGI
my $customer = param("Customer");
my $learn = param("Learn");
my $opinion = param("Site Opinion");
my $improvements = param("Site Iimprovement");
my $comments = param("comments");

my $head = Mail::Header->new;
# add an error handler here for the above

$head->add(From => 'Webmaster <[EMAIL PROTECTED]>');
$head->add(To   => '[EMAIL PROTECTED]');
$head->add(Subject => 'Peggy's Health Center Survey Response');

# Build the body of your message
my $body = <<END;
The following information has been sent via form:

Customer Type: $customer
Where They Found US: $learn
Site Opinion: $opinion
Site Improvements: $improvements
Comments: $comments
END

#Send the message
$mail = Mail::Internet->new(Header  => $head,
                            Body    => [$body],
                            Modify => 1);

print $mail->end('sendmail');


=== End of Code ===


Any ideas why I'm getting that error:
I'm using 5.8 version of perl and
have an older version 5.005_03
that does the same thing.

I appreciate the help.



--
************************************************************
*** Phillip B. Bruce                                     ***
***                                                      ***
*** "Politicians and diapers have one thing in common.   ***
***  They should both be changed regularly and for the   ***
***  same reason."                                       ***
***                                                      ***
************************************************************


-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to