Jump to content

[SOLVED] Send Mail Troubles...


holladb

Recommended Posts

Im having difficulties getting this mail function to send all the content in a shopping cart.

 

Here is the code:

 

################################################################
//ADD ALL ITEMS FROM CART INTO DATABASE!
################################################################

	//$tabel=$_SESSION['carttab'];
	for ($i=0; $i<count($cartT); $i++) {
		//$query2 = "SELECT * FROM product WHERE name='$pn1'";
		$query2 = "SELECT * FROM product WHERE idproduct=" . $cartT[$i]["id"];
		print($cartT[$i]["id"] . "<Br><br>");
		//print("Product ID: " . $cartT[$i]["id"] . " -- Products Amount Ordered: " . $cartT[$i]["nr"] . "\r\n");
		$pn = $cartT[$i]["id"];
		$pi = $cartT[$i]["nr"];
		$pon = "Product ID: " . $pn . " -- Products Amount Ordered: " . $pi . "\r\n";

		mysql_connect($host, $user, $pass) or die(mysql_error());
		mysql_select_db($dbase) or die(mysql_error());
		$results = mysql_query($query2) or die(mysql_error());
		$row = mysql_fetch_array($results) or die(mysql_error());
		$pt = $row['price'];

				if($row['inventory']>=$pi) {
				$np = $row['inventory']-$pi;
				} else {
				$np = $row['inventory'];
				}
						mysql_select_db($dbase) or die(mysql_error());
						mysql_query("UPDATE product SET inventory='$np' WHERE idproduct='$pn'") 
						or die(mysql_error());  

		mysql_select_db($dbase) or die(mysql_error());
		mysql_query("INSERT INTO orderproduct (idorder, idproduct, items, price, outfromstock) VALUES('$id', '$pn', '$pi', '$pt', '$pi') ") 
		or die(mysql_error());  
###################################################################
//END ADDING ITEMS TO DATABASE
###################################################################

#############################
//SEND MAIL
#############################
$to      = '[email protected]';
$subject = 'New Products Ordered by PayPal';
$message = "Dear Admin,\r\n\nThe following Items were added to Order # $id\r\n\n ".$pon;
$headers = 'From: [email protected]' . "\r\n" .
    'Reply-To: [email protected]' . "\r\n" .
    'X-Mailer: PHP/' . phpversion();

##############################
//END SEND MAIL
##############################
	}
mail($to, $subject, $message, $headers);

 

i have tried multiple ways, the way above sends each product as a single email.

 

any solutions?

Link to comment
https://forums.phpfreaks.com/topic/75672-solved-send-mail-troubles/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.