Re: displaying a message using perl code




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" <
dswiderski@xxxxxxxxx>'
;

# 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" <rcook@xxxxxxxxxxx>
To: "David Swiderski" <dswiderski@xxxxxxxxx>
Cc: <beginners@xxxxxxxx>
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
>
>

.



Relevant Pages

  • Re: Mail-merging with Word, MySQL... and Perl?
    ... Alt+F9 to toggle off their display. ... connection to my MySQL database on my Linux box. ... Or if a couple has its anniversary listed, I'll want to format ... the Perl script directly (which would be written to generate that data in ...
    (microsoft.public.word.mailmerge.fields)
  • Re: AW: Multi page form - cgi
    ... perl script. ... # display insert data page ... Shlomi Fish http://www.shlomifish.org/ ...
    (perl.beginners)
  • AW: Multi page form - cgi
    ... perl script. ... I'd suggest that you use one CGI parameter for page selection. ... # display insert data page ...
    (perl.beginners)
  • Re: Cyrillic web pages with Perl and MySQL
    ... > This is my simple Perl Script to display the database table on a web ... For some reason it does not display the Cyrillic words correctly: ... which is, I believe, the default PhpMyAdmin output charset, ... I'ld suggest to keep your charset in perl the same as in your html ...
    (comp.lang.perl.misc)
  • RE: Create a "cell button" to hide selected cells.
    ... To avoid cluttering up the worksheet with controls, I used a UserForm. ... The user clicks a button on the worksheet to display a UserForm ... Private Sub cmdSetWeeksToShow_Click ...
    (microsoft.public.excel.worksheet.functions)