Results 1 to 11 of 11
  1. #1
    Join Date
    Jan 2002
    Location
    Toronto, Canada
    Posts
    11,052

    Basic PHP help, please

    I use an affiliate script in which when an affiliate generated sale occurs, the script automatically sends notification of the sale to the affiliate. I would also like it to send me a copy of the email. I believe the following is the part of the code that needs to be modified. Which line exactly do I modify to add my email address?
    PHP Code:
    $i=0;
    $currentaff=$refid;
    $coolingoff=$pref[CoolingOff];

    $query="SELECT * FROM SendingEmails WHERE EmailID=4";
    $results=mysql_query($query);
    $sendingemails mysql_fetch_array($results);

    while (
    $i <= $pref[LevelsDeep]) {

            if (
    $currentaff) {

            
    $query="SELECT * FROM Affiliates WHERE AffID=$currentaff";
            
    $results=mysql_query($query);
            
    $aff mysql_fetch_array($results);

            
    $fullname $aff[FName] . " " $aff[LName];
            
    $fname=$aff[FName];
            
    $lname=$aff[LName];
            
    reset ($sendingemails);

            
    $recipient "$fullname <".$aff[Email].">";
            
    $headers ="From: ".$sendingemails[From]." <".$sendingemails[FromEmail].">";
            
    $subject $sendingemails[Subject];
            
    $message str_replace('[fullname]',$fullname,$sendingemails[Message]);
            
    $message str_replace('[fname]',$fname,$message);
            
    $message str_replace('[lname]',$lname,$message);
            
    $message str_replace('[coolingoff]',$coolingoff,$message);

            if (
    $aff[Email]) mail($recipient$subject$message$headers);

            
    $query="SELECT * FROM Referrals WHERE AffID='$currentaff'";
            
    $results=mysql_query($query);
            
    $row mysql_fetch_array($results);

            
    $currentaff=$row[ReferredBy];

            }
            
    $i++;

    Thanks for your help.

    Vito
    DemoDemo.com - Flash tutorials since 2002
    DemoWolf.com - 5,300+ Flash tutorials for hosting companies, incl. Voice tutorials

  2. #2
    Join Date
    May 2003
    Location
    Ohio
    Posts
    63
    I would do it later in the script than what you are showing us... Just take the mail() function that they are using, copy and paste it to a new line, and remove their email address (or the variable that holds it) and hardcode in your email address. To clarify, you now have two mail() functions, right next to each other... one sends to the affilliate, and the other to you.

    IANAL... I'd be careful however that this doesn't break any sort of license, or that the code doesn't check itself against a signature to prevent such alterations.

    --Paul
    -------------------------------
    Paul Henrich
    http://www.worldhive.net
    Email/SMS Blogging. Robust Business Hosting.

  3. #3
    Join Date
    Jan 2002
    Location
    Toronto, Canada
    Posts
    11,052
    Thanks, Paul. I'll try it.

    And no worries. I have the script creator's blessing to edit the code for this purpose...

    Vito
    DemoDemo.com - Flash tutorials since 2002
    DemoWolf.com - 5,300+ Flash tutorials for hosting companies, incl. Voice tutorials

  4. #4
    Join Date
    May 2001
    Location
    Dayton, Ohio
    Posts
    4,977
    vito,

    Not sure if you need anymore help but basicly copy this line:
    if ($aff[Email]) mail($recipient, $subject, $message, $headers);

    And make it:
    if ($aff[Email]) mail("you@yourdomain.com", $subject, $message, $headers);

  5. #5
    Join Date
    May 2003
    Location
    Ohio
    Posts
    63
    Hi,

    My bad, I didn't even see the mail() function in there, because I expected it in a codeblock on a newline instead of a one-line conditional.

    Try:

    if ($aff[Email]){
    mail($recipient, $subject, $message,$headers);
    mail("you@you.com",$subject,$message,$headers);
    }


    -Paul


    PS... I'd be inclined to check http://www.php.net/mail to see if there is a CC parameter so you don't have to call the function twice. That would be cool and would maybe save some server load.
    -------------------------------
    Paul Henrich
    http://www.worldhive.net
    Email/SMS Blogging. Robust Business Hosting.

  6. #6
    Join Date
    May 2001
    Location
    Dayton, Ohio
    Posts
    4,977
    Originally posted by worldhive
    PS... I'd be inclined to check http://www.php.net/mail to see if there is a CC parameter so you don't have to call the function twice. That would be cool and would maybe save some server load.
    You could write Cc: into $headers but sometimes you don't want the user to know its also being sent to the webmaster, or you want to use a private address just for these notices that you don't want the affilate to have..

    So the seperate mail function call helps keep things secret..

  7. #7
    Hello,

    http://us4.php.net/manual/en/function.mail.php

    Yes, there is a Cc & Bcc header options available, which would be the more efficient then copying and pasting the code. Just append your email address to the headers already created.

    Just make this line:

    Code:
      
    if ($aff[Email]) mail($recipient, $subject, $message, $headers);
    look like this:

    Code:
      
    
    $headers .= "\r\nBcc: your @ email.com";
    if ($aff[Email]) mail($recipient, $subject, $message, $headers);
    Bcc = Blind Carbon Copy, so the user won't know your getting a copy.

    Regards,
    --Jacob

  8. #8
    Join Date
    May 2003
    Location
    Ohio
    Posts
    63
    Good point!

    Just FYI incase anyone ever does want to use just one call... you can send to more than one person with just one mail call: just put all the recipients in the first parameter, separated by commas.
    -------------------------------
    Paul Henrich
    http://www.worldhive.net
    Email/SMS Blogging. Robust Business Hosting.

  9. #9
    Join Date
    Jan 2002
    Location
    Toronto, Canada
    Posts
    11,052
    Hey, thanks everyone. Thank God someone as PHP-illiterate as me has this place to come to when in need...



    Vito
    DemoDemo.com - Flash tutorials since 2002
    DemoWolf.com - 5,300+ Flash tutorials for hosting companies, incl. Voice tutorials

  10. #10
    Join Date
    Mar 2003
    Location
    Kathmandu, Nepal
    Posts
    3,982
    Vita: http://www.experts-exchange.com its a great resource for programming and lots of technical stuff. Its a very large community and has lots and lots and lots of programmers in almost any language.
    Kevin Ohashi - Founder of ReviewSignal.com - Honest Web Hosting Reviews
    Check out my 2021 WordPress Hosting Performance Benchmarks, the most comprehensive look at WP hosting performance

  11. #11
    Join Date
    Jan 2002
    Location
    Toronto, Canada
    Posts
    11,052
    Thanks, kohashi. It does appear to be a good resource. I have others bookmarked as well, but old habits die hard. I tend to prefer posting my questions here. When you have WHTitis, it's hard to stray. I'm like an old dog...

    Vito
    DemoDemo.com - Flash tutorials since 2002
    DemoWolf.com - 5,300+ Flash tutorials for hosting companies, incl. Voice tutorials

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •