beanymanuk Posted January 31, 2012 Share Posted January 31, 2012 Hi I have this code in a huge PHP file but when I have this code in the page wont load but if I take it out it does anyone see whats wrong with this code. if($sponsored == "s") { $message1 = " <html> <head> <title>Event Booking Confirmation</title> </head> <body> <p>Dear ".$title." ".$firstname." ".$lastname."</p> <p>You have succesfully booked a ticket for <b>".$enameQ."</b></p> <p>Here is your booking confirmation number: <b>BID".$booking_id."</b></p> <p>Tickets purchased</br> ".$team." ".$t2." ".$t3." ".$t4." Total Paid - £".$price."</p> <p>We have received your booking details and they have been passed to the event holder</p> <p>*Subject to payment being made</p> <p>The event organiser will be in contact shortly with further event details.</p> <p>To start your fundraising efforts you can now create a fundraising page by clicking <a href='http://www.test.co.uk/register/test'><u>here</u></a><p> <p>Thank You for your booking.</p> <br/> <p>Kind Regards</p> <p>Test Team</p> <br/> <img src='http://www.test.com/images/email-logo.jpg' alt='logo'> </body> </html> "; $headers1 = "From: Test <noreply@test.co.uk>\n"; $headers1 .= "MIME-Version: 1.0\r\n"; $headers1 .= "Content-Type: multipart/mixed; "; $headers1 .= "boundary=".$num."\r\n"; $headers1 .= "--$num\r\n"; $headers1 .= "Content-Type: text/html; charset=iso-8859-1\r\n"; mail($email, $subject1, $message1, $headers1); } elseif($sponsored == "ns") { $message1 = " <html> <head> <title>Event Booking Confirmation</title> </head> <body> <p>Dear ".$title." ".$firstname." ".$lastname."</p> <p>You have succesfully booked a ticket for <b>".$enameQ."</b></p> <p>Here is your booking confirmation number: <b>BID".$booking_id."</b></p> <p>Tickets purchased</br> ".$team." ".$t2." ".$t3." ".$t4." Total Paid - ".$price."</p> <p>We have received your booking details and they have been passed to the event holder</p> <p>*Subject to payment being made</p> <p>The event organiser will be in contact shortly with further event details.</p> <p>Thank You for your booking.</p> <br/> <p>Kind Regards</p> <p>Test Team</p> <br/> <img src='http://www.test.com/images/email-logo.jpg' alt='logo'> </body> </html> "; $headers1 = "From: Test <noreply@test.com>\n"; $headers1 .= "MIME-Version: 1.0\r\n"; $headers1 .= "Content-Type: multipart/mixed; "; $headers1 .= "boundary=".$num."\r\n"; $headers1 .= "--$num\r\n"; $headers1 .= "Content-Type: text/html; charset=iso-8859-1\r\n"; mail($email, $subject1, $message1, $headers1); } Quote Link to comment https://forums.phpfreaks.com/topic/256118-page-not-working-with-this-code-in/ Share on other sites More sharing options...
fife Posted January 31, 2012 Share Posted January 31, 2012 put this code at the top of the page and load the page again. Should give you the errors error_reporting(E_ALL); ini_set("display_errors", 1); Quote Link to comment https://forums.phpfreaks.com/topic/256118-page-not-working-with-this-code-in/#findComment-1312948 Share on other sites More sharing options...
beanymanuk Posted January 31, 2012 Author Share Posted January 31, 2012 Strangely my code works executes ok but obviously doesnt send the emails when I take out this line from the two if statements in the code I posted mail($email, $subject1, $message1, $headers1); Is there any expectational reason why the above line would cause problems? Quote Link to comment https://forums.phpfreaks.com/topic/256118-page-not-working-with-this-code-in/#findComment-1312975 Share on other sites More sharing options...
spiderwell Posted January 31, 2012 Share Posted January 31, 2012 check with host on mail set ups , you might need to add more parameters like ini_set("sendmail_from", $from); Quote Link to comment https://forums.phpfreaks.com/topic/256118-page-not-working-with-this-code-in/#findComment-1312981 Share on other sites More sharing options...
AyKay47 Posted January 31, 2012 Share Posted January 31, 2012 from the manual: Return Values Returns TRUE if the mail was successfully accepted for delivery, FALSE otherwise. It is important to note that just because the mail was accepted for delivery, it does NOT mean the mail will actually reach the intended destination. do you have access to the php.ini file? Quote Link to comment https://forums.phpfreaks.com/topic/256118-page-not-working-with-this-code-in/#findComment-1312983 Share on other sites More sharing options...
beanymanuk Posted January 31, 2012 Author Share Posted January 31, 2012 I don't have direct access but I can get access to it. What do I need to look for do in php.ini? There are other places in the file where the following line of code is executed ok mail($email, $subject1, $message1, $headers1); Quote Link to comment https://forums.phpfreaks.com/topic/256118-page-not-working-with-this-code-in/#findComment-1312993 Share on other sites More sharing options...
Pikachu2000 Posted January 31, 2012 Share Posted January 31, 2012 The problem is probably with the formatting of the headers, or some other parameter and not with php's mail() function. Wrap the mail() function in var_dump(), and if mail() doesn't return false, the message was successfully passed to the MTA, and you'd need to have a look at the mail logs to see if you can figure out what's going on. echo '<br>mail() function returned:<br>'; var_dump(mail($email, $subject1, $message1, $headers1)); echo '<br>On line: ' . __LINE__ . '<br>'; Quote Link to comment https://forums.phpfreaks.com/topic/256118-page-not-working-with-this-code-in/#findComment-1313001 Share on other sites More sharing options...
spiderwell Posted January 31, 2012 Share Posted January 31, 2012 if mail works elsewhere, then mail should work anywhere check what you are passing it, compare it to what is passed to one that DOES work. Quote Link to comment https://forums.phpfreaks.com/topic/256118-page-not-working-with-this-code-in/#findComment-1313002 Share on other sites More sharing options...
beanymanuk Posted January 31, 2012 Author Share Posted January 31, 2012 Pikachu2000 from the test echo '<br>mail() function returned:<br>'; var_dump(mail($email, $subject1, $message1, $headers1)); echo '<br>On line: ' . __LINE__ . '<br>'; I received mail() function returned: Quote Link to comment https://forums.phpfreaks.com/topic/256118-page-not-working-with-this-code-in/#findComment-1313023 Share on other sites More sharing options...
Pikachu2000 Posted January 31, 2012 Share Posted January 31, 2012 Look in the page source, sometimes it gets output with its own formatting and can 'break' the formatting that's already in the html. Quote Link to comment https://forums.phpfreaks.com/topic/256118-page-not-working-with-this-code-in/#findComment-1313024 Share on other sites More sharing options...
mikosiko Posted January 31, 2012 Share Posted January 31, 2012 Hi I have this code in a huge PHP file but when I have this code in the page wont load but if I take it out it does anyone see whats wrong with this code. ...... do you mean that your "huge PHP" script doesn't do nothing (white screen) with the posted code in and it works fine without it?... if that is the case maybe the inclusion of the posted code in your "huge php" is triggering a syntax error, hence the behavior. if that is not the case, why you don't isolate the posted code, provide dummy values to the variables and test it alone?... I did and your posted code is fine and capable to send mails without any modification on my side. Quote Link to comment https://forums.phpfreaks.com/topic/256118-page-not-working-with-this-code-in/#findComment-1313048 Share on other sites More sharing options...
beanymanuk Posted February 1, 2012 Author Share Posted February 1, 2012 The rest of the page does not load after this line mail($email, $subject1, $message1, $headers); Quote Link to comment https://forums.phpfreaks.com/topic/256118-page-not-working-with-this-code-in/#findComment-1313238 Share on other sites More sharing options...
beanymanuk Posted February 1, 2012 Author Share Posted February 1, 2012 Still not working This is the full section of code elseif($action=="confirm" && trim($title)!=NULL && trim($firstname)!=NULL && trim($lastname)!=NULL && trim($email)!=NULL && trim($add1)!=NULL && trim($city)!=NULL && trim($county)!=NULL && trim($postcode)!=NULL && trim($tel)!=NULL){ $supporters_details_result = $wpdb->get_results("SELECT * FROM events WHERE id='$eid' LIMIT 0, 1"); foreach($supporters_details_result as $supporters_details_result){ $name = ucwords($supporters_details_result->ename); } $price = $_POST['grandtotal']; $indatabase = NULL; $check_sessid_result = $wpdb->get_results("SELECT * FROM events_bookings WHERE booking_id='$booking_id' ORDER BY id LIMIT 0, 1"); foreach($check_sessid_result as $check_sessid_result){ $indatabase = $check_sessid_result->id; } if($indatabase==NULL){ $event_result = mysql_query ("INSERT INTO events_bookings (id, booking_id, event_id, displayname, title, firstname, lastname, email, add1, add2, city, county, postcode, tel, how, ref, status, date, team, quantityteam, tt1, quantitytt1, tt2, quantitytt2, tt3, quantitytt3, grandtotal) VALUES('NULL', '$booking_id', '$eid', '$displayname', '$title', '$firstname', '$lastname', '$email', '$add1', '$add2', '$city', '$county', '$postcode', '$tel', '$how', '$ref', '1', '$bookdate', '$teamticket' , '$quantity', '$t2ticket', '$quantity1', '$t3ticket', '$quantity2', '$t4ticket', '$quantity3', '$price')"); } $subject = 'Event Booking received'; $supporters_details_result = $wpdb->get_results("SELECT * FROM events WHERE id='$eid' LIMIT 0, 1"); foreach($supporters_details_result as $supporters_details_result){ $priceQ = $supporters_details_result->price; $priceQ = number_format($priceQ, 2, '.', ''); $enameQ = $supporters_details_result->ename; $causeid = $supporters_details_result->cause_id; $sponsored = $supporters_details_result->type; } $getcauseemail = $wpdb->get_results("SELECT * FROM causes WHERE id='$causeid' LIMIT 0, 1"); foreach($getcauseemail as $getcauseemail){ $cemail = $getcauseemail->email; } if($quantity != 0) { $team = "Team x $quantity</br>"; } if($quantity1 != 0) { $t2 = "$t2ticket x $quantity1</br>"; } if($quantity2 != 0) { $t3 = "$t3ticket x $quantity2</br>"; } if($quantity3 != 0) { $t4 = "$t4ticket x $quantity3</br>"; } $to = 'testemail@test.com'; // message $message = " <html> <head> <title>Event Booking received</title> </head> <body> <p>Event Booking received</p> <p>User: ".$title." ".$firstname." ".$lastname." (".$email.")</br> Event ID: ".$enameQ."</br> Booking ID: BID".$booking_id."</br> Address Line 1: ".$add1."</br> Address Line 2: ".$add2."</br> City: ".$city."</br> County: ".$county."</br> Postcode: ".$postcode."</br> Telephone: ".$tel."</br></br> Tickets purchased</br> ".$team." ".$t2." ".$t3." ".$t4." Total Paid - £".$price."</p> <p>Please login and check payment status of booking to see if payment has been recieved</p> <p>Kind Regards</p> <p>Test Team</p> <br/> <img src='http://www.test.co.uk/images/email-logo.jpg' alt='logo'> </body> </html> "; // To send HTML mail, the Content-type header must be set $headers = "From: Test <noreply@test.co.uk>\n"; $headers .= "MIME-Version: 1.0\r\n"; $headers .= "Content-Type: multipart/mixed; "; $headers .= "boundary=".$num."\r\n"; $headers .= "--$num\r\n"; $headers .= "Content-Type: text/html; charset=iso-8859-1\r\n"; // Mail it //echo "TOP<br>"; //echo "EMAIL: ".$to."<br>"; //echo "SUBJECT: ".$subject."<br>"; //echo "MESSAGE: ".$message."<br>"; //echo "HEADER: ".$headers."<br>"; //end of news nottification $num = md5(time()); $subject1 = "Event Booking Confirmation"; $geteventtype = $wpdb->get_results("SELECT * FROM events WHERE id='$eid'"); foreach($geteventtype as $geteventtype){ $sponsored = $geteventtype->type; } //echo $sponsored; if($sponsored == "s") { //echo "Sponsored"; $message1 = " <html> <head> <title>Event Booking Confirmation</title> </head> <body> <p>Dear ".$title." ".$firstname." ".$lastname."</p> <p>You have succesfully booked a ticket for <b>".$enameQ."</b> at Simply Fundraising!</p> <p>Here is your booking confirmation number: <b>BID".$booking_id."</b></p> <p>Tickets purchased</br> ".$team." ".$t2." ".$t3." ".$t4." Total Paid - £".$price."</p> <p>We have received your booking details and they have been passed to the event holder</p> <p>*Subject to payment being made</p> <p>The event organiser will be in contact shortly with further event details.</p> <p>To start your fundraising efforts you can now create a fundraising page by clicking <a href='http://www.test/register/fundraising-pages'><u>here</u></a><p> <p>Thank You for your booking.</p> <br/> <p>Kind Regards</p> <p>Test Team</p> <br/> <img src='http://www.test.co.uk/images/email-logo.jpg' alt='logo'> </body> </html> "; $headers1 = "From: TEST <noreply@test.co.uk>\n"; $headers1 .= "MIME-Version: 1.0\r\n"; $headers1 .= "Content-Type: multipart/mixed; "; $headers1 .= "boundary=".$num."\r\n"; $headers1 .= "--$num\r\n"; $headers1 .= "Content-Type: text/html; charset=iso-8859-1\r\n"; } elseif($sponsored == "ns") { //echo "Non-Sponsored"; $message1 = " <html> <head> <title>Event Booking Confirmation</title> </head> <body> <p>Dear ".$title." ".$firstname." ".$lastname."</p> <p>You have succesfully booked a ticket for <b>".$enameQ."</b></p> <p>Here is your booking confirmation number: <b>BID".$booking_id."</b></p> <p>Tickets purchased</br> ".$team." ".$t2." ".$t3." ".$t4." Total Paid - ".$price."</p> <p>We have received your booking details and they have been passed to the event holder</p> <p>*Subject to payment being made</p> <p>The event organiser will be in contact shortly with further event details.</p> <p>Thank You for your booking.</p> <br/> <p>Kind Regards</p> <p>Test Team</p> <br/> <img src='http://www.test.co.uk/images/email-logo.jpg' alt='logo'> </body> </html> "; $headers1 = "From:Test <noreply@test.co.uk>\n"; $headers1 .= "MIME-Version: 1.0\r\n"; $headers1 .= "Content-Type: multipart/mixed; "; $headers1 .= "boundary=".$num."\r\n"; $headers1 .= "--$num\r\n"; $headers1 .= "Content-Type: text/html; charset=iso-8859-1\r\n"; } //echo "BOTTOM<br>"; //echo "EMAIL: ".$email."<br>"; //echo "SUBJECT: ".$subject1."<br>"; //echo "MESSAGE: ".$message1."<br>"; //echo "HEADER: ".$headers."<br>"; //Problem line of code everything after this line doesn't execute mail($to, $subject, $message, $headers); if($price==0){ ?> <div style=" float:right; width:700px;"> <div class="box_content_right"> <div class="reg_header">Event Booking - Thank You</div> <div class="reg_content"> <p style="margin:0px 50px 0px 50px; padding-top:20px; padding-bottom:20px;"><strong>Thank you.</strong><br/>We have received your booking details and event holder will contact you shortly.</p> </div> <div class="reg_footer"> </div> </div> </div> <?php }else{ ?> <div style=" float:right; width:700px;"> <div class="box_content_right"> <div class="reg_header">Event Booking - Payment</div> <div class="reg_content"> <p style="margin:0px 50px 0px 50px; padding-top:20px; padding-bottom:20px;">Please wait while we transfer you to the secure payment area to pay <strong>£<?php echo $price;?></strong> for your event ticket/s.<br><br><img src="<?php bloginfo('stylesheet_directory'); ?>/images/paymentcards.JPG"/></p> <div style="margin-left:auto; margin-right:auto; text-align:center;"> <form action="https://www.paypal.com/cgi-bin/webscr" method="post" name="paypal"> <input type="hidden" name="cmd" value="_donations"> <input type="hidden" name="business" value="paypal@test.co.uk"> <input type="hidden" name="lc" value="US"> <input type="hidden" name="item_name" value="Event Payment (<?php echo $booking_id;?>) by <?php echo $displayname;?> - <?php echo $email;?>"> <input type="hidden" name="country_code" value="GB" /> <input type="hidden" name="amount" value="<?php echo $price;?>" /> <input type="hidden" name="return" value="<?php bloginfo('url'); ?>/event?booking=<?php echo $eid;?>&action=approved&sessionid=<?php echo $booking_id;?>"> <input type="hidden" name="cancel_ return" value=<?php bloginfo('url'); ?>/event?booking=<?php echo $eid;?>&action=canceled&sessionid=<?php echo $booking_id;?>" /> <input type="hidden" name="currency_code" value="GBP"> <input type="hidden" name="no_note" value="0"> <input type="hidden" name="currency_code" value="GBP"> <input type="hidden" name="login_email" value="<?php echo $email;?>" /> <input type="hidden" name="first_name" value="<?php echo $firstname;?>" /> <input type="hidden" name="last_name" value="<?php echo $lastname;?>" /> <input type="hidden" name="country_code" value="GB" /> <input type="hidden" name="address1" value="<?php echo $add1;?>" /> <input type="hidden" name="address2" value="<?php echo $add2;?>" /> <input type="hidden" name="city" value="<?php echo $city;?>" /> <input type="hidden" name="email" value="<?php echo $email;?>" /> <input type="hidden" name="H_PhoneNumber" value="<?php echo $tel;?>" /> <input type="hidden" name="bn" value="PP-DonationsBF:btn_donateCC_LG.gif:NonHostedGuest"> <!---<input type="submit" value="Pay with PayPal™" style="margin-left:auto; margin-right:auto;"/>---> </div> </div> <script type="text/javascript"> setTimeout(document.paypal.submit(),10000); </script> <div class="reg_footer"> </div> </div> </div> <?php } NOTE: I have changed email addresses etc to test.com just for confidentiality Any questions just let me know and apologies for the messy code. Quote Link to comment https://forums.phpfreaks.com/topic/256118-page-not-working-with-this-code-in/#findComment-1313254 Share on other sites More sharing options...
mikosiko Posted February 1, 2012 Share Posted February 1, 2012 echo your variables $to, $subject, $message and $headers before that line and check if all of them are correct. Quote Link to comment https://forums.phpfreaks.com/topic/256118-page-not-working-with-this-code-in/#findComment-1313347 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.