Results 1 to 11 of 11
Thread: Basic PHP help, please
-
05-23-2003, 11:14 PM #1Eternal Member
- 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++;
}
VitoDemoDemo.com - Flash tutorials since 2002
DemoWolf.com - 5,300+ Flash tutorials for hosting companies, incl. Voice tutorials
-
05-23-2003, 11:21 PM #2Junior Guru Wannabe
- 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.
-
05-23-2003, 11:23 PM #3Eternal Member
- 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...
VitoDemoDemo.com - Flash tutorials since 2002
DemoWolf.com - 5,300+ Flash tutorials for hosting companies, incl. Voice tutorials
-
05-23-2003, 11:40 PM #4Web Hosting Master
- 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);
-
05-23-2003, 11:48 PM #5Junior Guru Wannabe
- 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.
-
05-23-2003, 11:54 PM #6Web Hosting Master
- 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.
So the seperate mail function call helps keep things secret..
-
05-23-2003, 11:59 PM #7Disabled
- Join Date
- Feb 2003
- Posts
- 14
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);
Code:$headers .= "\r\nBcc: your @ email.com"; if ($aff[Email]) mail($recipient, $subject, $message, $headers);
Regards,
--Jacob
-
05-23-2003, 11:59 PM #8Junior Guru Wannabe
- 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.
-
05-24-2003, 01:52 AM #9Eternal Member
- 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...
VitoDemoDemo.com - Flash tutorials since 2002
DemoWolf.com - 5,300+ Flash tutorials for hosting companies, incl. Voice tutorials
-
05-24-2003, 11:30 AM #10Retired Moderator
- 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
-
05-24-2003, 11:39 AM #11Eternal Member
- 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...
VitoDemoDemo.com - Flash tutorials since 2002
DemoWolf.com - 5,300+ Flash tutorials for hosting companies, incl. Voice tutorials