PorkPie Posted September 11, 2007 Share Posted September 11, 2007 Hi ppl. I have some php from a booking sheet of mine. I am trying to send an automatic email with an e-voucher number to the customer. I'm still learning php coding, so I'm pretty rubbish still. Can someone help me find a solution to this part of the code: // Send e-voucher email to customer (near the bottom): snip>>>>> <? ob_start(); error_reporting("null"); session_start(); include("includes/config.php"); $userdet=array(); //insert the table if(empty($_SESSION['bookingid'])) { $userdet['detid']=''; $userdet['contname'] = $_REQUEST['contname']; $userdet['contmidname '] = $_REQUEST['contmidname']; $userdet['contsurname'] = $_REQUEST['contsurname']; $userdet['contaddr'] = $_REQUEST['contaddr']; $userdet['contcity'] = $_REQUEST['contcity']; $userdet['contpostcode'] = $_REQUEST['contpostcode']; $userdet['realship'] = $_REQUEST['relation']; $userdet['contemail'] = $_REQUEST['contemail']; $userdet['contnumber'] = $_REQUEST['contnumber']; $userdet['bdefname'] = $_REQUEST['bdefirstname']; $userdet['bdemldename'] =$_REQUEST['bdemiddlename']; $userdet['bdesurname'] = $_REQUEST['bdesurname']; $userdet['bdeaddr'] = $_REQUEST['bdeaddr']; $userdet['bdecity'] = $_REQUEST['bdecity']; $userdet['bdepostcode'] = $_REQUEST['bdepostcode']; $userdet['grmfname'] = $_REQUEST['grmfirstname']; $userdet['grmmldename'] = $_REQUEST['grmmiddlename']; $userdet['grmsurname'] = $_REQUEST['grmsurname']; $userdet['grmaddr'] = $_REQUEST['grmaddr']; $userdet['grmcity'] = $_REQUEST['grmcity']; $userdet['grmpostcode'] = $_REQUEST['grmpostcode']; $userdet['bdrpartname'] = $_REQUEST['bdeparent']; $userdet['grmpartname'] = $_REQUEST['grmparent']; $userdet['bestmanname'] = $_REQUEST['bestmanname']; $userdet['bridesmaid'] = $_REQUEST['bridename']; $res=db_insert('tbluserdetails',$userdet); if($res) { $rest=db_getRs('tbluserdetails','contemail="'.$_REQUEST['contemail'].'" and weddate="0000-00-00"'); $sql2=mysql_fetch_array($rest); $bookingid=$sql2[0]; session_register("bookingid"); } } //update the table if($_SESSION['bookingid']) { $userdet1=array(); $userdet1['contname'] = $_REQUEST['contname']; $userdet1['contaddr'] = $_REQUEST['contaddr']; $userdet1['contcity'] = $_REQUEST['contcity']; $userdet1['contpostcode'] = $_REQUEST['contpostcode']; $userdet1['realship'] = $_REQUEST['relation']; $userdet1['contemail'] = $_REQUEST['contemail']; $userdet1['contnumber'] = $_REQUEST['contnumber']; $userdet1['bdefname'] = $_REQUEST['bdefirstname']; $userdet1['bdemldename'] =$_REQUEST['bdemiddlename']; $userdet1['bdesurname'] = $_REQUEST['bdesurname']; $userdet1['bdeaddr'] = $_REQUEST['bdeaddr']; $userdet1['bdecity'] = $_REQUEST['bdecity']; $userdet1['bdepostcode'] = $_REQUEST['bdepostcode']; $userdet1['grmfname'] = $_REQUEST['grmfirstname']; $userdet1['grmmldename'] = $_REQUEST['grmmiddlename']; $userdet1['grmsurname'] = $_REQUEST['grmsurname']; $userdet1['grmaddr'] = $_REQUEST['grmaddr']; $userdet1['grmcity'] = $_REQUEST['grmcity']; $userdet1['grmpostcode'] = $_REQUEST['grmpostcode']; $userdet1['bdrpartname'] = $_REQUEST['bdeparent']; $userdet1['grmpartname'] = $_REQUEST['grmparent']; $userdet1['bestmanname'] = $_REQUEST['bestmanname']; $userdet1['bridesmaid'] = $_REQUEST['bridename']; $res=db_update('tbluserdetails',$userdet1,'detid="'.$_SESSION['bookingid'].'"'); } $res2=db_getRs('tbluserdetails','detid="'.$_SESSION['bookingid'].'"'); $sql=mysql_fetch_array($res2); $wtime=explode(":", $sql['wedtime']); $wmin=explode(" ",$wtime[1]); $cdate=$_REQUEST['cdate']; $cutdate=explode("-",$sql['weddate']); //calculate the date if($_REQUEST['cdate']) { $cutdate=explode("-", $_REQUEST['cdate']); } $year=$cutdate[0]; $mon=$cutdate[1]; $day=$cutdate[2]; switch ($mon) { case 1: $mon="Jan"; break; case 2: $mon="Feb"; break; case 3: $mon="Mar"; break; case 4: $mon="Apr"; break; case 5: $mon="May"; break; case 6: $mon="Jun"; break; case 7: $mon="Jul"; break; case 8: $mon="Aug"; break; case 9: $mon="Sep"; break; case 10: $mon="Oct"; break; case 11: $mon="Nov"; break; case 12: $mon="Dec"; break; } // Send e-voucher email to customer ob_start(); require("phpmailer/class.phpmailer.php"); include("includes/config.php"); $mail = new PHPMailer(); $mail->IsSMTP(); // send via SMTP $mail->Host = "localhost"; // SMTP servers $mail->SMTPAuth = true; // turn on SMTP authentication $mail->Username = ""; // SMTP username $mail->Password = ""; /*if($_REQUEST['weddingdet']) { $res=db_getRs('tbluserdetails','contemail="'.$_REQUEST['contemail'].'"'); $aff=mysql_affected_rows(); if($aff) { $sql=mysql_fetch_array($res);*/ if($_SESSION['bookingid']) { $userdet1=array(); $userdet1['contname'] = $_REQUEST['contname']; $userdet1['contemail'] = $_REQUEST['contemail']; $subject="E-voucher details from the company"; $message="Dear $contname <br> Your e-voucher is: 45345345<br> ". ; $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers .= 'From: Support <support@mycompany.com>' . "\r\n"; $mail->From = "support@mycompany.com"; $mail->FromName = "mycompany.com"; $mail->AddAddress($to); $mail->WordWrap = 50; // set word wrap $mail->AddAttachment("/var/tmp/file.tar.gz"); // attachment $mail->AddAttachment("/tmp/image.jpg", "new.jpg"); $mail->IsHTML(true); $mail->Subject = $subject; $mail->Body = $message; $mail->AltBody = $message; $a=mail($to, $subject, $message, $headers); if(!$a) { $message1="Mail was not sent. Please Check Mail Address"; echo $message1; } else { header("location:thank_you.php"); } } else { $msg="Email address not found<br> Enter email address for your e-voucher"; } } ?> <<<<< Thanks guys. Quote Link to comment Share on other sites More sharing options...
MadTechie Posted September 11, 2007 Share Posted September 11, 2007 1. if its "Urgent" please post in the freelance section with an offer. 2. please use code tags. 3. define the problem! "not working" isn't usful... have you got php installed.. maybe the problems their! Quote Link to comment Share on other sites More sharing options...
PorkPie Posted September 11, 2007 Author Share Posted September 11, 2007 1. - 2. - 3. PHP works on the server. Don't see that you'd really need anything else. Code should be self-explanatory. Quote Link to comment Share on other sites More sharing options...
ToonMariner Posted September 11, 2007 Share Posted September 11, 2007 you could tell us what errors you are getting (if any) or what the result of the script is (like is any email sent at all or email sent but no attachement - that kind of thing really helps. Otherwise we have to trawl through you code which we can't be bothered to do most of the time... Quote Link to comment Share on other sites More sharing options...
PorkPie Posted September 11, 2007 Author Share Posted September 11, 2007 I get a blank page. Nothing on it. Quote Link to comment Share on other sites More sharing options...
PorkPie Posted September 11, 2007 Author Share Posted September 11, 2007 This is where it is wrong... >>>>> // Send e-voucher email to customer ob_start(); require("phpmailer/class.phpmailer.php"); include("includes/config.php"); $mail = new PHPMailer(); $mail->IsSMTP(); // send via SMTP $mail->Host = "localhost"; // SMTP servers $mail->SMTPAuth = true; // turn on SMTP authentication $mail->Username = ""; // SMTP username $mail->Password = ""; /*if($_REQUEST['weddingdet']) { $res=db_getRs('tbluserdetails','contemail="'.$_REQUEST['contemail'].'"'); $aff=mysql_affected_rows(); if($aff) { $sql=mysql_fetch_array($res);*/ if($_SESSION['bookingid']) { $userdet1=array(); $userdet1['contname'] = $_REQUEST['contname']; $userdet1['contemail'] = $_REQUEST['contemail']; $subject="E-voucher details from the company"; $message="Dear $contname Your e-voucher is: 45345345 ". ; $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers .= 'From: Support <support@mycompany.com>' . "\r\n"; $mail->From = "support@mycompany.com"; $mail->FromName = "mycompany.com"; $mail->AddAddress($to); $mail->WordWrap = 50; // set word wrap $mail->AddAttachment("/var/tmp/file.tar.gz"); // attachment $mail->AddAttachment("/tmp/image.jpg", "new.jpg"); $mail->IsHTML(true); $mail->Subject = $subject; $mail->Body = $message; $mail->AltBody = $message; $a=mail($to, $subject, $message, $headers); if(!$a) { $message1="Mail was not sent. Please Check Mail Address"; echo $message1; } else { header("location:thank_you.php"); } } else { $msg="Email address not found Enter email address for your e-voucher"; } } <<<<<<< Quote Link to comment Share on other sites More sharing options...
ToonMariner Posted September 11, 2007 Share Posted September 11, 2007 if this is on a live server try putting ini_set('error_reporting', E_ALL); at the vrey top of your script. Quote Link to comment Share on other sites More sharing options...
magnetica Posted September 11, 2007 Share Posted September 11, 2007 Where are you testing this script? Remotely or locally? Quote Link to comment Share on other sites More sharing options...
PorkPie Posted September 11, 2007 Author Share Posted September 11, 2007 Remotely. I'll put in ini_set('error_reporting', E_ALL); shortly just waiting for some other work to complete. Also, do you or do you know anyone who does work with PHP & Flash? I want to change part of my site to flash with PHP & MYSQL backend. Quote Link to comment Share on other sites More sharing options...
MadTechie Posted September 11, 2007 Share Posted September 11, 2007 also comment out the ob_start();'s for testing you may get an error about the header but then you know its getting their! Quote Link to comment Share on other sites More sharing options...
xyn Posted September 11, 2007 Share Posted September 11, 2007 you have ob_start(); but you dont have ob_end_flush(); at the very bottom. Quote Link to comment Share on other sites More sharing options...
magnetica Posted September 11, 2007 Share Posted September 11, 2007 Also, do you or do you know anyone who does work with PHP & Flash? To be honest if you know a bit of actionscript, a bit about PHP and XML then it's really not that hard. Just search Google for "php xml and flash " Quote Link to comment Share on other sites More sharing options...
PorkPie Posted September 11, 2007 Author Share Posted September 11, 2007 Everything was working until I added the // Send e-voucher email to customer section. Quote Link to comment Share on other sites More sharing options...
xyn Posted September 11, 2007 Share Posted September 11, 2007 So. what's not working? what are the problems you're encountering? you cant expect us to mind read. Quote Link to comment Share on other sites More sharing options...
PorkPie Posted September 11, 2007 Author Share Posted September 11, 2007 Your powers of mind reading failing you? The auto emailing out using contemail request. Quote Link to comment Share on other sites More sharing options...
MadTechie Posted September 11, 2007 Share Posted September 11, 2007 Oh thats usful... i give TechieOut Quote Link to comment Share on other sites More sharing options...
xyn Posted September 11, 2007 Share Posted September 11, 2007 I dont know much about smtp; but surly if $mail->SMTPAuth = true; // turn on SMTP authentication and your user/pass is blank. thats your problem? Quote Link to comment Share on other sites More sharing options...
PorkPie Posted September 11, 2007 Author Share Posted September 11, 2007 Lighten up MadTechie. ini_set('error_reporting', E_ALL); didn't show anything either. I think I'll have to start from scratch. :-X Quote Link to comment Share on other sites More sharing options...
xyn Posted September 11, 2007 Share Posted September 11, 2007 yer i think you should too. Quote Link to comment Share on other sites More sharing options...
PorkPie Posted September 11, 2007 Author Share Posted September 11, 2007 I don't think that's the prob. xyn, it all worked before I put in the code starting from // Send e-voucher email to customer Quote Link to comment Share on other sites More sharing options...
xyn Posted September 11, 2007 Share Posted September 11, 2007 start again explai nyour problem, any errors Quote Link to comment Share on other sites More sharing options...
MadTechie Posted September 11, 2007 Share Posted September 11, 2007 1. does it email (check junk/spam) 2. any errors (did you comment out the ob_start()'s 3. are your email server details correct ? 4. try echoing some date ie $_REQUEST['contemail'] $aff $_SESSION['bookingid'] we need details worst case add die("TEST"); at the start then test you get t he message TEST, move it down until you stop getting it, the line before is probably the problem! Quote Link to comment Share on other sites More sharing options...
PorkPie Posted September 11, 2007 Author Share Posted September 11, 2007 Sure.... 1. The code was all working before I added the // Send e-voucher email to customer 2. I wanted to use the $_REQUEST['contemail']; to auto email the customer an email when he/she submitted this part of this booking form (there are several parts) 3. Now all I get is a blank page. Granted there is a page before this that puts things into variables/arrays but I tried completing that too but still get a blank on this page. 4. I assume the code that I have for auto emailing is wrong. I can see no errors, just a blank page. Can I simplify this auto email code some way? Quote Link to comment Share on other sites More sharing options...
magnetica Posted September 11, 2007 Share Posted September 11, 2007 Why not post us a link? Quote Link to comment Share on other sites More sharing options...
PorkPie Posted September 11, 2007 Author Share Posted September 11, 2007 I removed the whole section of this and the page came back. >>>>>> // Send e-voucher email to customer ob_start(); require("phpmailer/class.phpmailer.php"); include("includes/config.php"); $mail = new PHPMailer(); $mail->IsSMTP(); // send via SMTP $mail->Host = "localhost"; // SMTP servers $mail->SMTPAuth = true; // turn on SMTP authentication $mail->Username = ""; // SMTP username $mail->Password = ""; /*if($_REQUEST['weddingdet']) { $res=db_getRs('tbluserdetails','contemail="'.$_REQUEST['contemail'].'"'); $aff=mysql_affected_rows(); if($aff) { $sql=mysql_fetch_array($res);*/ $message = " $todayis [EST] \n Attention: $attn \n From: $name ($visitormail)\n Senders Message: $notes \n Introducing: \n Couples Name: $coupleintroname \n Couples Email: $coupleintromail \n Couples Address: $coupleintroaddr \n Couples Telephone: $coupleintrotel \n Additional Info : IP = $ip \n Browser Info: $httpagent \n Referral : $httpref \n "; $from = "From: $visitormail\r\n"; mail("****", $subject, $message, $from); if($_SESSION['bookingid']) { $userdet1=array(); $userdet1['contname'] = $_REQUEST['contname']; $userdet1['contemail'] = $_REQUEST['contemail']; $subject="E-voucher details from the company"; $message="Dear $contname <br> Your e-voucher is: 45345345<br> ". ; $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers .= 'From: Login Details<support@mycompany.com>' . "\r\n"; $mail->From = "support@mycompany.com"; $mail->FromName = "mycompany.com"; $mail->AddAddress($to); $mail->WordWrap = 50; // set word wrap $mail->AddAttachment("/var/tmp/file.tar.gz"); // attachment $mail->AddAttachment("/tmp/image.jpg", "new.jpg"); $mail->IsHTML(true); $mail->Subject = $subject; $mail->Body = $message; $mail->AltBody = $message; $a=mail($to, $subject, $message, $headers); if(!$a) { $message1="Mail does not sent. Please Check Mail Id"; echo $message1; } else { header("location:thank_you.php?forgetpass=1"); } } else { $msg="User Name not found <br> Enter Correct User Name"; } <<<<< Quote Link to comment 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.