Jump to content

mail and $body troubles


NeMoD

Recommended Posts

How do I assign multiple strings to $body?

 

     if ($cart) {	

	$to = "email@mail.com";
	$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
Share on other sites

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

 

     if ($cart) {   
      
      $to = "email@mail.com";
      $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

Link to comment
Share on other sites

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.