Jump to content

[SOLVED] sending array through mail()


NeMoD

Recommended Posts

$body = "";
if (is_array($_SESSION[$sessionarray])) {
    foreach($_SESSION[$sessionarray] as $key => $val) {
           $body .= $val . PHP_EOL;
    }
}
if (mail($to, $subject, $body)) {
    echo("<p>success!</p>");
} else {
    echo("<p>Failed...</p>");
}

 

I tested it and it only sends a blank message  ???

<?
	session_start();
	$sessionarray = array(number1,number2,number3);

	$to = "[email protected]";
	$subject = "hey";
	$body = "";
	if (is_array($_SESSION[$sessionarray])) {
		foreach($_SESSION[$sessionarray] as $key => $val) {
           	$body .= $val . PHP_EOL;
		}
	}

	if (mail($to, $subject, $body)) {
		echo("<p>success!</p>");
	} else {
   			echo("<p>Failed...</p>");
	}
?>

Sorry for the double post, but it seems I can't edit my post twice.

You're script is working now, I didn't put the $_SESSION in when I declared the array.

So onto my next problem: How do I fill this array, $_SESSION[$sessionarray]?

		
foreach ($contents as $product_id=>$qty) {
		$sql = "SELECT * FROM product_listing WHERE product_id = '$product_id'";
		$result = $db->query($sql);
		$row = $result->fetch();
		$_SESSION[$sessionarray] = $product_id; // here we go
		extract($row);
		$output[] = '<tr>';
		$output[] = '<td><img src="/images/uploads/'.$image.'" width="165" height="124" />';
		$output[] = '<td><a href="cart.php?action=delete&product_id='.$product_id.'" class="r">Remove</a></td>';
		$output[] = '<td><input type="text" name="qty'.$product_id.'" value="'.$qty.'" size="3" maxlength="3" /></td>';
		$output[] = '</tr>';
		$output[] = $_SESSION[$sessionarray].'</br>'; //test
	}

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.