Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Send mail only 1X

Status
Not open for further replies.

JimJx

Technical User
Feb 16, 2001
202
US
I want to make sure that an email gets sent 1x. However, this one gets sent every time someone uses a form to dl a file.

What I WANT to happen is the email gets sent when the page is loaded, that happens. But when the users do a download on the page, it gets sent again...

If the form is needed I can past that also.....

The email is at the bottom of the page....

Code:
#!/usr/bin/perl

use CGI qw(:standard Vars);
use CGI::Carp qw(fatalsToBrowser warningsToBrowser);

require 'WAccessLib.pl';


my $Name;
my $Pass;
my $query = new CGI;
my $newUser ='../newUser.html';
my $first_name = $query->param("first_name");
my $last_name = $query->param("last_name");
my $company = $query->param("company");
my $address = $query->param("address");
my $city = $query->param("city");
my $state = $query->param("state");
my $zip = $query->param("zip");
my $phone = $query->param("phone");
my $fax = $query->param("fax");
my $email = $query->param("email");
my $mailed = $query->param("mailed");
my ($Name, $Pass, $Used);
my $Track;

&NewUsr();
&OutPg();

sub NewUsr() {
my $flag = 0;
open (INF, "user.txt") or die ("Unable to open the file user.txt. $!");
   local($^I, @ARGV) = ('.bak', 'user.txt');
   while (<>) {
      if (/^(.+)(\|No)$/ && $flag == 0) {
         $flag = 1;
         ($Name, $Pass, $Used) = split (/\|/);
         print "$Name\|$Pass\|Yes\n";
      }
      else {
         print;
      }
   }
close (INF);
}

sub OutPg() {
$Track = "$Name";
print header();
open (PAGE, "$newUser") or die ("Unable to open the file newUser. $!");
     while (<PAGE>)                
     {
        s/%%name%%/$Name/g;
        s/%%pass%%/$Pass/g;
        s/%%first_name%%/$first_name/g;
        s/%%last_name%%/$last_name/g;
        s/%%company%%/$company/g;
        s/%%address%%/$address/g;
        s/%%city%%/$city/g;
        s/%%state%%/$state/g;
        s/%%zip%%/$zip/g;
        s/%%phone%%/$phone/g;
        s/%%fax%%/$fax/g;
        s/%%email%%/$email/g;
        s/%%track%%/$Track/g;    
        s/%%mailed%%/$mailed/g; 
        print $_;
}
close (PAGE);
}

if ($mailed eq "No") {
open (MAIL, "|/usr/sbin/sendmail -t");
print MAIL "From: roy\@jrcapitalandinvestment.com\n";
print MAIL "To:jfarthing\@iwon.com\n";
print MAIL "Subject: Form Submission\n\n";
print MAIL "First Name: $first_name\n";
print MAIL "Last Name: $last_name\n";
print MAIL "Company:  $company\n";
print MAIL "Address: $address\n";
print MAIL "City: $city\n";
print MAIL "State: $state\n";
print MAIL "Zip: $zip\n";
print MAIL "Phone: $phone\n";
print MAIL "Fax: $fax\n";
print MAIL "Email: $email\n";
print MAIL "Reference Number: $Track\n";
print MAIL "\n.\n";
close ( MAIL );
$mailed = "Yes";
}
 
Please disregard, wrong forum. :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top