Jump to content

PHP email system


gavin.sibley

Recommended Posts

hello,

 

im trying to set up an email system that is automatically triggered.

 

<?php

}else{

}

if($register_error == "none"){

}else{

echo("$register_error");

}

if($_GET[deposit_complete]){

if($temp[sentwelcome] == "0"){

$desc = "was sent a conformation letter for  their booking on the $slide[event_day] $slide[event_month], $slide[event_year]";

$time = time();

$susername = "$slide[title]. $slide[fname] $slide[lname]";

$url = "/img/iconReminder.png";

$query = mysql_query("INSERT INTO `activity` (`time`, `desc`, `url`, `username`) VALUES ('$time', '$desc', '$url', '$susername')");

$to = "info@soundboxaudio.com";

$from = "$site";

$reqemail = "$site";

$subject = "Thank you for booking with Soundbox Entertainment";

$headers = "From: " . strip_tags($from) . "\r\n";

$headers .= "Reply-To: ". strip_tags($reqemail) . "\r\n";

$headers .= "MIME-Version: 1.0\r\n";

$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";

$message = '<html><body>';

$message .= "<br />

Dear $temp[title]. $temp[fname] $temp[lname],<br /><br />

 

Many thanks for choosing Soundbox Entertainment, to supply the entertainment for your";

if($temp[service] == "Stand Alone"){ $message .= " event.<br />"; }else{ }

if($temp[service] == "Party"){ $message .= " party.<br />"; }else{ }

if($temp[service] == "Wedding"){ $message .= " wedding.<br />"; }else{ }

$message .= "We are able to confirm receipt of your £50.00 Deposit.

<br />To confirm the details, we are supplying entertainment services on the $temp[event_day] $temp[event_month], $temp[event_year].<br /><br />

If you have any further requirements for your";

if($temp[service] == "Stand Alone"){ $message .= " event, "; }else{ }

if($temp[service] == "Party"){ $message .= " party, "; }else{ }

if($temp[service] == "Wedding"){ $message .= " wedding, "; }else{ }

$message .= "please contact us as early as<br />

possible as we have many bolt on products that we can offer to make your ";

if($temp[service] == "Stand Alone"){ $message .= "event "; }else{ }

if($temp[service] == "Party"){ $message .= "party "; }else{ }

if($temp[service] == "Wedding"){ $message .= "wedding "; }else{ }

$message .= "a special one.<br />

We will contact you about a week prior to the event in order to discuss the final arrangements.<br /><br />

Here at Soundbox we have found that the best form of advertising in our industry is recommendation, and<br />

we would be grateful if you were able to recommend our services to your friends and family, to help we can<br />

offer you a £10.00 Tesco™ voucher, for any bookings made. Just tell your friends or family to mention that<br />

you made the recommendation when booking.<br /><br />

Please be aware that the balance of payment is due 7 days prior to the event.<br />

We would again like to thank you for your business and remind you to think of us for any further parties or events<br />

you may be planning in the future.

<br /><br /><br />

Best regards,<br />

Gavin Sibley<br />

Soundbox Entertainment

<br /><br />

<span style='color: #888888;'>$site[phone]<br />

http://soundboxentertainment.co.uk/</span>

<br /><br />";

$message .= "</body></html>";

mail($to, $subject, $message, $headers);

 

 

 

$query = mysql_query("UPDATE `temp_users` SET `sentwelcome` = '1' WHERE `ip` = '$temp[ip]'");

}else{

}

?>

 

 

i want this email to be sent when the field 'payeddeposit' is yes and also when 'sentwelcome' is 0.

 

cannot seem to get it to work.

 

thanks,

gavin

Link to comment
Share on other sites

dude, seriously : use [ php] [ /php] BB tags around your code, it makes a massive difference.  Also, could you maybe go into some detail about what it's not doing, when it's not doing it, what it's doing instead and how much of what it is supposed to be doing is going ok?

 

to think of your script in an automotive sense:  saying "my code broke down somewhere in my page" is like calling up a rescue company and saying "my car broke down somewhere in this country".  They may get to your car, but it's going to take a lot longer than if you give town/city, neerest landmark, street name, how many miles down that rode you are, color of nearest parked vehicle etc. etc. etc.  You see, by taking the time and helping us, we in turn will need to spend less time before we can help you. ;D

Link to comment
Share on other sites

<?php
}else{
}
if($register_error == "none"){
}else{
echo("$register_error");
}
if($_GET[deposit_complete]){
if($temp[sentwelcome] == "0"){
$desc = "was sent a conformation letter for  their booking on the $slide[event_day] $slide[event_month], $slide[event_year]"; 
$time = time();
$susername = "$slide[title]. $slide[fname] $slide[lname]";
$url = "/img/iconReminder.png";
$query = mysql_query("INSERT INTO `activity` (`time`, `desc`, `url`, `username`) VALUES ('$time', '$desc', '$url', '$susername')");
$to = "info@soundboxaudio.com";
$from = "$site[email]";
$reqemail = "$site[email]";
$subject = "Thank you for booking with Soundbox Entertainment";
$headers = "From: " . strip_tags($from) . "\r\n";
$headers .= "Reply-To: ". strip_tags($reqemail) . "\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
$message = '<html><body>';
$message .= "<br />
Dear $temp[title]. $temp[fname] $temp[lname],<br /><br />

Many thanks for choosing Soundbox Entertainment, to supply the entertainment for your";
if($temp[service] == "Stand Alone"){ $message .= " event.<br />"; }else{ }
if($temp[service] == "Party"){ $message .= " party.<br />"; }else{ }
if($temp[service] == "Wedding"){ $message .= " wedding.<br />"; }else{ }
$message .= "We are able to confirm receipt of your £50.00 Deposit.
<br />To confirm the details, we are supplying entertainment services on the $temp[event_day] $temp[event_month], $temp[event_year].<br /><br />
If you have any further requirements for your";
if($temp[service] == "Stand Alone"){ $message .= " event, "; }else{ }
if($temp[service] == "Party"){ $message .= " party, "; }else{ }
if($temp[service] == "Wedding"){ $message .= " wedding, "; }else{ }
$message .= "please contact us as early as<br />
possible as we have many bolt on products that we can offer to make your ";
if($temp[service] == "Stand Alone"){ $message .= "event "; }else{ }
if($temp[service] == "Party"){ $message .= "party "; }else{ }
if($temp[service] == "Wedding"){ $message .= "wedding "; }else{ }
$message .= "a special one.<br />
We will contact you about a week prior to the event in order to discuss the final arrangements.<br /><br />
Here at Soundbox we have found that the best form of advertising in our industry is recommendation, and<br />
we would be grateful if you were able to recommend our services to your friends and family, to help we can<br />
offer you a £10.00 Tesco™ voucher, for any bookings made. Just tell your friends or family to mention that<br />
you made the recommendation when booking.<br /><br />
Please be aware that the balance of payment is due 7 days prior to the event.<br />
We would again like to thank you for your business and remind you to think of us for any further parties or events<br />
you may be planning in the future.
<br /><br /><br />
Best regards,<br />
Gavin Sibley<br />
Soundbox Entertainment
<br /><br />
<span style='color: #888888;'>$site[phone]<br />
http://soundboxentertainment.co.uk/</span>
<br /><br />";
$message .= "</body></html>";
mail($to, $subject, $message, $headers);



$query = mysql_query("UPDATE `temp_users` SET `sentwelcome` = '1' WHERE `ip` = '$temp[ip]'");
}else{
}
?>

 

(better? lol)

 

when someone makes a booking on the website, this email should get automatically sent to them when they get returned from paypal to my website. Currently it is not doing this, neither is it updating the database 'sentwelcome' field to 1, which it should also do.

 

i believe its somewhere in the line

 

if($_GET[deposit_complete]){
if($temp[sentwelcome] == "0"){

 

also, from what i can see, its sending the email to the various different bookings depending on the persons i.p address (as it shouldnt change between them making the booking and them returning to the site which is approxs 3-4 mins.)

 

is there any way to make this email send automatically when this script is run to everyone in the database that has the payeddeposit field set to yes and the sent welcome field set to 0?

 

many thanks,

gavin

Link to comment
Share on other sites

what's your error reporting set to? you should be getting a screen full of "Warning: Undefined Constant xxx assuming 'xxx'" if it's set to all.  When addressing array values, unless the key is actualy a defined constant, you should always wrap in single quotes so instead of

if($_GET[deposit_complete]){
if($temp[sentwelcome] == "0"){

You should have

if($_GET['deposit_complete']){
if($temp['sentwelcome'] == "0"){

It should still run -all be it unhappily- with your own array values, but superglobals can do some funny things at times ($_GET is a superglobal by the way)

 

also I see this here:

if($register_error == "none"){
}else{

and kind of need to ask you: what's the point in that then?

 

and another thing, when you are accessing array key values within pased strings you should wrap them in {} -

$query = mysql_query("UPDATE `temp_users` SET `sentwelcome` = '1' WHERE `ip` = '{$temp['ip']}'");

 

Let's start with those changes and see what happens

Link to comment
Share on other sites

Right then,

 

i have tested the system and it nearly works, however there are two small problems with it.

 

1. The activity table update doesnt work, it inserts the information into the database but doesnt put there names into it.

 

i.e

 

this: -

 

$desc = "was sent a conformation letter for  their booking on the $slide[event_day] $slide[event_month], $slide[event_year]"; 
$time = time();
$susername = "$slide[title]. $slide[fname] $slide[lname]";
$url = "/img/iconReminder.png";
$query = mysql_query("INSERT INTO `activity` (`time`, `desc`, `url`, `username`) VALUES ('$time', '$desc', '$url', '$susername')");

 

does this

 

. was sent a conformation letter for their booking on the ,

 

instead of this

 

Mr (Firstname)(secondname) was sent a conformation letter for their booking on the (date)

 

 

problem 2.

 

the email is sent perfectly to my own inbox, however it is not sent to the client, which i think is something to do with this.

 

$to = "{$slide[email]}; info@soundboxaudio.com";

 

thanks,

gav

Link to comment
Share on other sites

ueah, your going to need to put the single quotes around all your array keys (so everything that is inside a set of []) and also wrap all array key reffrences within double quote strings inside the curly braces, including

$desc = "was sent a conformation letter for  their booking on the {$slide['event_day']} {$slide['event_month']}, {$slide['event_year']}"; 

There is also nothing to put the title,first,last information at the start of the $desc =  line, so you probably want it to look like:

$desc = "{$slide['title']}. {$slide['fname']} {$slide['lname']} was sent a conformation letter for their booking on the {$slide['event_day']} {$slide['event_month']}, {$slide['event_year']}"; 

Link to comment
Share on other sites

when i include that, the email isnt sent at all, not even to my own inbox.

 

also i am returned to my website as normal but instead of loading the home page with a message at the top saying thank you, it is returning me to a different page on the site, with no content on it at all, just with the word NULL written across the page.

Link to comment
Share on other sites

You can create a test page on your server that submits the expected post/get data to the script you are trying to test so that you can get it working independent of the paypal process (which will also demonstrate that you shouldn't rely solely on the visitor being returned to your site to consider the payment valid and complete) or you can also use the paypal sandbox instead of the 'live' paypal processing.

 

You should should also have php's error_reporting set to E_ALL so that all the php detected errors will be reported.

 

Is there some reason you haven't posted all the code on the page (less any sensitive information in it), particularly the code that is setting the $slide array and any code from where the $slide array is being set up to the code you have posted, since something in that code could be clearing those values?

Link to comment
Share on other sites

hey Muddy_Funster

 

it is a completely random page of the site, and at no point during the booking process do i go onto or use this page.

 

thanks

Well something somewhere point's to it or else it would be showing up.  your script can't just invent a page to display without being told to display it somewhere in the code, if it's passing to another page then it will loose variable values that arn't passed along.  Try a search/find for the page refference in all your code and see if anything comes back, it's got to be there somewhere, it's either that or something external is having an effect.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.