gavin.sibley Posted March 20, 2012 Share Posted March 20, 2012 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 = "[email protected]"; $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 Quote Link to comment https://forums.phpfreaks.com/topic/259322-php-email-system/ Share on other sites More sharing options...
Muddy_Funster Posted March 20, 2012 Share Posted March 20, 2012 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. Quote Link to comment https://forums.phpfreaks.com/topic/259322-php-email-system/#findComment-1329337 Share on other sites More sharing options...
gavin.sibley Posted March 20, 2012 Author Share Posted March 20, 2012 <?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 = "[email protected]"; $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 Quote Link to comment https://forums.phpfreaks.com/topic/259322-php-email-system/#findComment-1329338 Share on other sites More sharing options...
Muddy_Funster Posted March 20, 2012 Share Posted March 20, 2012 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 Quote Link to comment https://forums.phpfreaks.com/topic/259322-php-email-system/#findComment-1329345 Share on other sites More sharing options...
gavin.sibley Posted March 20, 2012 Author Share Posted March 20, 2012 thanks for that, i have made these changes and i will test to see what happens now? (im just looking for where i can change the deposit amount to £0.01 so i dont have to keep paying myself £50 to test it!) thanks, gav Quote Link to comment https://forums.phpfreaks.com/topic/259322-php-email-system/#findComment-1329355 Share on other sites More sharing options...
gavin.sibley Posted March 20, 2012 Author Share Posted March 20, 2012 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]}; [email protected]"; thanks, gav Quote Link to comment https://forums.phpfreaks.com/topic/259322-php-email-system/#findComment-1329363 Share on other sites More sharing options...
Muddy_Funster Posted March 20, 2012 Share Posted March 20, 2012 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']}"; Quote Link to comment https://forums.phpfreaks.com/topic/259322-php-email-system/#findComment-1329368 Share on other sites More sharing options...
gavin.sibley Posted March 20, 2012 Author Share Posted March 20, 2012 thanks for all your help. tried this, however it didnt make any difference, for some reason two commas are being put into the username field and also, two commas are being put in the end of the description field where the date should be. Quote Link to comment https://forums.phpfreaks.com/topic/259322-php-email-system/#findComment-1329370 Share on other sites More sharing options...
Muddy_Funster Posted March 20, 2012 Share Posted March 20, 2012 whats does a die(var_dump($slide)) produce if you put it on the line above $desc=? Quote Link to comment https://forums.phpfreaks.com/topic/259322-php-email-system/#findComment-1329372 Share on other sites More sharing options...
gavin.sibley Posted March 20, 2012 Author Share Posted March 20, 2012 it causes a syntax error and nothing on the entire site will load. gav Quote Link to comment https://forums.phpfreaks.com/topic/259322-php-email-system/#findComment-1329373 Share on other sites More sharing options...
Muddy_Funster Posted March 20, 2012 Share Posted March 20, 2012 yip, forgot the ; at the end of the line sorry Quote Link to comment https://forums.phpfreaks.com/topic/259322-php-email-system/#findComment-1329375 Share on other sites More sharing options...
gavin.sibley Posted March 20, 2012 Author Share Posted March 20, 2012 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. Quote Link to comment https://forums.phpfreaks.com/topic/259322-php-email-system/#findComment-1329379 Share on other sites More sharing options...
Muddy_Funster Posted March 20, 2012 Share Posted March 20, 2012 just with the word NULL written across the page.That's one of the options that I was expecting to get. the $slip[] array has not been defined on this page, so it had no content (is NULL) - I assume it's on a page one or two before the one we're working on just now? Quote Link to comment https://forums.phpfreaks.com/topic/259322-php-email-system/#findComment-1329383 Share on other sites More sharing options...
PFMaBiSmAd Posted March 20, 2012 Share Posted March 20, 2012 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? Quote Link to comment https://forums.phpfreaks.com/topic/259322-php-email-system/#findComment-1329388 Share on other sites More sharing options...
gavin.sibley Posted March 20, 2012 Author Share Posted March 20, 2012 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 Quote Link to comment https://forums.phpfreaks.com/topic/259322-php-email-system/#findComment-1329441 Share on other sites More sharing options...
Muddy_Funster Posted March 20, 2012 Share Posted March 20, 2012 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. Quote Link to comment https://forums.phpfreaks.com/topic/259322-php-email-system/#findComment-1329446 Share on other sites More sharing options...
gavin.sibley Posted March 20, 2012 Author Share Posted March 20, 2012 I think i have accidentally fixed it. when i change all the $Slide to $temp it seems to start working, should this have any adverse effect on anything else from what you can see? many thanks, gavin Quote Link to comment https://forums.phpfreaks.com/topic/259322-php-email-system/#findComment-1329451 Share on other sites More sharing options...
Nodral Posted March 20, 2012 Share Posted March 20, 2012 That all depends where $temp is set and what it contains. Without someone reading every line of your code it's gonna be pretty impossible to say what will be affected where. Quote Link to comment https://forums.phpfreaks.com/topic/259322-php-email-system/#findComment-1329454 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.