Jump to content

mail and $body troubles


NeMoD

Recommended Posts

How do I assign multiple strings to $body?

 

     if ($cart) {	

	$to = "[email protected]";
	$subject = "my subject";
	$body .= $_POST['firstname'];
	$body .= $_POST['lastname'];
	$body .= $_POST['street'];
	$body .= $_POST['zipcode'];
	$body .= $_POST['country'];
	$body .= $_POST['email'];
	$body .= $_POST['phonenumber'];
	if (is_array($_SESSION[mailorder])) {
		foreach($_SESSION[mailorder] as $key => $val) {
           	$body .= $val . PHP_EOL;
		}
	}

	if (mail($to, $subject, $body)) {
		echo('<p>Order Submitted!');
	} else {
   			echo('<p>Order failed, please try again!');
	}
    }

$mailorder is an array containing all the product numbers, that part is working fine.

Link to comment
https://forums.phpfreaks.com/topic/165383-mail-and-body-troubles/
Share on other sites

It's only sending the product numbers from $mailorder  ???

 

     if ($cart) {   
      
      $to = "[email protected]";
      $subject = "my subject";
      if (is_array($_SESSION['mailorder'])) {
         foreach($_SESSION['mailorder'] as $key => $val) {
              $body .= $val . PHP_EOL;
         }
      }
      
      $body .= $_POST['firstname'].$_POST['lastname'].$_POST['street'].$_POST['zipcode'].$_POST['country'].$_POST['email'].$_POST['phonenumber'];

      if (mail($to, $subject, $body)) {
         echo('<p>Order Submitted!');
      } else {
            echo('<p>Order failed, please try again!');
      }
    }

 

Where one issue may be in your code is references to: $_SESSION[mailorder] ... it should be $_SESSION['mailorder'] (notice the use of the single quote). Other than that it should work fine.

 

 

put the quotes in, still only sends the product numbers from mailorder

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.