Php Mail

Hi i have some problem with this code,

  • Firstly I wanted it so it sent one email… although it would either. Give me $msg1 or $msg2 and online ONE ROW of $msg1??..

    • I tried adding a GLOBAL variable, although that didnt seem to do anything as it would have had to escape TWO scopes…
  • Secondly i split it into two mail functions which arnt as good but i just need it functional.

    • This didnt work as even though when i echo’d the function and it would display all 3, When i received the email, there was only one displayed
      again…
  • Ive tried If, didnt work… As soon as it leaves that Scope for no matter what, if to mail or just be echoed it will only display onee…

can someone help me please its really annoying.
http://imageupload.org/getlinks.php?s=d2d30369e18cacc9996159410c22e0c1

Many thanks
Lewis Stevens

[php]<?php
ob_start();
include ‘login/dbc.php’;
page_protect();

if (isset($_SESSION[‘user_id’])) {
echo "
p{
color:#000;
font-weight:bold;
font-family: arial, sans-serif;
font-size:13px;
}
p.var{
color:#000;
font-weight:normal;
font-family: arial, sans-serif;
font-size:13px;
}
h1{
color:#000;
font-weight:bold;
font-family:arial,sans-serif;
font-size:20px;
}
";

$userid = $_SESSION['user_id'];
$contact_brendon = "[email protected]";


$msg_start = "<table style='border:1px solid #000; padding:10px; text-align:left;' width='500px'>";
$msg_blankrow = "<tr><td>&nbsp;</td><td>&nbsp;</td></tr>";
$msg_end = "</table><br>"; 
	
$result1 = mysql_query("SELECT * FROM cart WHERE cart_user='$userid'");

while($row1 = mysql_fetch_array($result1)){
	$prod = $row1['product_id'];
	$quantity = $row1['quantity'];
	$cart_user = $row1['cart_user'];

$result2 = mysql_query("SELECT * FROM products WHERE product_id = '$prod'");

while($row2 = mysql_fetch_assoc($result2)) {
	$product_id = $row2['product_id'];
	$product_name = $row2['product_name'];
	$product_desc = $row2['product_desc'];

$msg1 = "



Product Details






Product Id:




$product_id






Product Name:




$product_name






Product Description:   




$product_desc






Product Quantity:   




$quantity



“;
};
$message_part1 = “$msg_start $msg1 $msg_end”;
};
$subject1 = “$cart_user - Invoice Enquiry”;
$headers = ‘MIME-Version: 1.0’ . “\r\n”;
$headers .= ‘Content-type: text/html; charset=iso-8859-1’ . “\r\n”;
mail(”$contact_brendon",$subject1,$message_part1, $headers);
$result3 = mysql_query(“SELECT * FROM users WHERE id=’$userid’”);
while($row3 = mysql_fetch_array($result3)){
	$user_email = $row3['user_email'];
	$contact_name = $row3['contact_name'];
	$company_name = $row3['company_name'];
	$account_no = $row3['account_no'];
	$tel = $row3['tel'];
	$mobile = $row3['mobile'];
	$address1 = $row3['address1'];
	$address2 = $row3['address2'];
	$address3 = $row3['address3'];
	$address4 = $row3['address4'];
	$address5 = $row3['address5'];
	$postcode = $row3['postcode'];
	$country = $row3['country'];	
	
	$subject2 = "$account_no - Invoice Enquiry";
	$msg2 = "<tr>
				<td>
					<h1>Account Details</h1>
				</td>
				<td>
				</td>
			</tr>
			<tr>
				<td style='width:150px;'>
					<p>Account Number:</p>
				</td>
				<td>
					<p class='var'>$account_no</p>
				</td>
			</tr>
			<tr>
				<td>
					<p>Company Name:</p>
				</td>
				<td>
					<p class='var'>$company_name</p>
				</td>
			</tr>
			<tr>
				<td>
					<p>Contact Name:</p>
				</td>
				<td>
					<p class='var'>$contact_name</p>
				</td>
			</tr>
			<tr>
				<td>
					<p>Contact Email:</p>
				</td>
				<td>
					<p class='var'>$user_email</p>
				</td>
			</tr>
			<tr>
				<td>
					<p>Telephone:</p>
				</td>
				<td>
					<p class='var'>$tel</p>
				</td>
			</tr>
			<tr>
				<td>
					<p>Mobile:</p>
				</td>
				<td>
					<p class='var'>$mobile</p>
				</td>
			</tr>
			<tr><td>&nbsp;</td><td>&nbsp;</td></tr>
			<tr>
				<td>
					<h1>Delivery Details</h1>
				</td>
				<td>
				</td>
			</tr>
			<tr>
				<td style='width:150px;'>
					<p>Address:</p>
				</td>
				<td>
					<p class='var'>$address1</p>
				</td>
			</tr>
			<tr>
				<td>
				</td>
				<td>
					<p class='var'>$address2</p>
				</td>
			</tr>
			<tr>
				<td>
				</td>
				<td>
					<p class='var'>$address3</p>
				</td>
			</tr>
			<tr>
				<td>
				</td>
				<td>
					<p class='var'>$address4</p>
				</td>
			</tr>
			<tr>
				<td>
				</td>
				<td>
					<p class='var'>$address5</p>
				</td>
			</tr>
			<tr>
				<td>
					<p>Postcode</p>
				</td>
				<td>
					<p class='var'>$postcode</p>
				</td>
			</tr>
			<tr>
				<td>
					<p>Country</p>
				</td>
				<td>
					<p class='var'>$country</p>
				</td>
			</tr>";
	
	$message_part2 = "$msg_start $msg2 $msg_end";
	};
$subject1 = "$cart_user - Invoice Enquiry";
$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
mail("$contact_brendon",$subject2,$message_part2, $headers);

ob_end_flush();
}
else
{ echo “Error, Please Go Back And Try Again, Else Contact Brendon.”; }

?>[/php]

Sponsor our Newsletter | Privacy Policy | Terms of Service