Hi Owen, Thanks for your reply to my email.  Follows is my perl script which
I'm trying to get it to display a message.

perl script email.pl
#!/usr/bin/perl
####################################################################
#
# email.pl
#
# emails the data from the alumni mailing list.html form.
#
# Last modified 09/16/2005
#
# modified file email.pl by David Swiderski
#
####################################################################

# Points $mailprogram to sendmail - used to send notification
  $mailprogram = '/usr/sbin/sendmail';

# Where should notification be send ?
  $notify_email = '"David Swiderski" <
[EMAIL PROTECTED]>'
;

# Should notification be send (yes/no) ?
  $donotify="yes";

# Where should the visitor be redirected to after the update ?
  $redir="http://wrossmacdonaldschool.on.ca/alumni%20mailing%20list.html";;

# Changing anything below this line is not recommended

# Gets the data from the form
  &parse_form;
  $first_name = $FORM{'first_name'};
  $last_name = $FORM{'last_name'};
  $maiden_name = $FORM{'maiden_name'};
  $street_address = $FORM{'street_address'};
  $apartment_number = $FORM{'apartment_number'};
  $home_city = $FORM{'home_city'};
  $province_state = $FORM{'province_state'};
  $postal_code = $FORM{'postal_code'};
  $email_address = $FORM{'email_address'};
  $phone_number = $FORM{'phone_number'};

# Calls subroutine to validate the input
# Converts < to &lt; to avoid abuse (<script etc)
  &validate;
  $first_name =~ s/</\&lt;/g;
  $last_name =~ s/</\&lt;/g;
  $maiden_name =~ s/</\&lt;/g;
  $street_address =~ s/</\&lt;/g;
  $apartment_number =~ s/</\&lt;/g;
  $home_city =~ s/</\&lt;/g;
  $province_state =~ s/</\&lt;/g;
  $postal_code =~ s/</\&lt;/g;
  $email_address =~ s/</\&lt;/g;
  $phone_number =~ s/</\&lt;/g;

# Converts linebreaks (\n) to <br>

# Calls notification-routine if selected
  if(lc($donotify) eq "yes")  {
     &notify;              }

# Redirects to selected page
print "Location: $redir\n\n";
exit;

sub validate {

  $errors="";

  if($first_name eq "")    {
    $errors=$errors . "Please enter your name !\\n";
                     }

  if ($errors ne "")     {
    print "Content-type: text/html\n\n";
    print "<html>\n";
    print "<head>\n";
    print "<title></title>\n";
    print "</head>\n";
    print "<body>\n";
    print "<script language=\"JavaScript\">\n";
    print "{\n";
    print "alert(\"$errors\");\n";
    print "history.back();\n";
    print "}\n";
    print "</script>\n";
    print "</body></html>";
    exit;
}
}

sub notify {

if($email ne "")   {
    $from = $email; }
else                {
    $from = $notify_email;
                    }

open(MAIL, "|/usr/sbin/sendmail -t") || die
"Content-type: text/text\n\nCant open /usr/sbin/sendmail!";
print MAIL "From: $from\n";
print MAIL "To: $notify_email\n";
print MAIL "Subject: Updating my reunion mailing list information\n\n";
print MAIL "Name: $first_name $last_name\n\n";
print MAIL "Maiden Name: $maiden_name\n\n";
print MAIL "Street Address: $street_address\n\n";
print MAIL "Apartment Number: $apartment_number\n\n";
print MAIL "City: $home_city, $province_state\n\n";
print MAIL "Postal Code: $postal_code\n\n";
print MAIL "email: $email_address\n\n";
print MAIL "phone: $phone_number\n\n";
close(MAIL);
}

sub parse_form {
   read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
   if (length($buffer) < 10) {
         $buffer = $ENV{QUERY_STRING};
    }

  @pairs = split(/&/, $buffer);
   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;
   }
}

text file message.pl
#!/usr/bin/perl
####################
print "Content-type: text/html\n\n";
print "your information has been sent.";
print "Thank You for joining the alumni community!";
print "We hope to see you at the next reunion.";

----- Original Message -----

From: "Owen Cook" <[EMAIL PROTECTED]>
To: "David Swiderski" <[EMAIL PROTECTED]>
Cc: <beginners@perl.org>
Sent: Saturday, September 17, 2005 9:47 PM
Subject: Re: displaying a message using perl code


>
> On Sat, 17 Sep 2005, David Swiderski wrote:
>
> >
> > My perl question is, is there a simple way to display some text/message
on the users screen such as
> >
> > your information has been sent.
> > Thank You for joining the alumni community!
> > We hope to see you at the next reunion.
>
>
> Well the answer to your question is probably yes, but you have not
> provided any code so there is no way of telling what is happening.
>
> Basically if you were to write the script from scratch, you would use
> CGI.pm
>
> Display form if no data submitted
> Send mail and display response if form has been completed
>
>
>
>
>
> Owen
>
>


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to