Jump to content

Recommended Posts

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);
} 		

Link to comment
https://forums.phpfreaks.com/topic/256118-page-not-working-with-this-code-in/
Share on other sites

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?

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?

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>';

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.

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.

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.