Jump to content

php array to email body,,,separate lines


walkerwilly77

Recommended Posts

can you one of the php master can help me out with this

 

this is my array output

Array ( [0] => WI BLACK CHERRY BASE [1] => 1 [2] => WI STRAWBERRY BASE [3] => 1 )

 

 

this is the buttom I am using to past the value

 

<form id="form1" name="form1" method="post" action="/storescripts/mailcart.php">

<input type="hidden" name="message" id="message" value="<?php echo $mail_id_array; ?>" />

<input type="submit" name="button" id="button" value="Send Order" />

</form>

 

 

this is the mailcart.php

<?php

$message = '';

$name = "wesrt";

$email = "[email protected]";

$message .= $_POST[message];

$formcontent=" From: $name \n Message: $message";

$recipient = "[email protected]";

$subject = "Order Form";

$mailheader = "From: $email \r\n";

//mail($recipient, $subject, $formcontent, $mailheader) or die("Error!");

mail($recipient, $subject, $message, $mailheader) or die("Error!");

print_r($message);

//header( 'Location: http://www.xsn.com/index.php' ) ;

//echo "Thank You!";

?>

 

I am getting this:

WI BLACK CHERRY BASE .--->.1<br>WI STRAWBERRY BASE .--->.1<br>

 

 

and I would like to have the following result:

 

WI BLACK CHERRY BASE .--->.1

WI STRAWBERRY BASE .--->.1

Link to comment
https://forums.phpfreaks.com/topic/273775-php-array-to-email-bodyseparate-lines/
Share on other sites

I dont see anything in that code that sets the content type as html, or anything else for that matter. You don't show any other html deffinitions or tags. If you want to send html mails you need to set the content-type and form the page properly.

 

Edt: typo

thanks for the fast response

 

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

//this is my cart page cart.php here I do render my dynamic cart table wich is the values i want to have in my email body separated in diferent lines

//I delete some of the top code because i do not want to give you innecessary code to read but workss

//in the html body you will find the buttom I do use to send the value to my cartemail.php

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

 

<?php

session_start(); // Start session first thing in script

// Script Error Reporting

error_reporting(E_ALL);

ini_set('display_errors', '1');

// Connect to the MySQL database

include "storescripts/connect_to_mysql.php";

?><p><?php

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

// Section 5 (render the cart for the user to view on the page)

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

$cartOutput = "";

$cartTotal = "";

$quantity = "";

$pp_checkout_btn = '';

$product_id_array = '';

$mail_id_array = '';

$sentoemail=array();

if (!isset($_SESSION["cart_array"]) || count($_SESSION["cart_array"]) < 1) {

$cartOutput = "<h2 align='center'>Your shopping cart is empty</h2>";

} else {

// Start PayPal Checkout Button

$pp_checkout_btn .= '<form action="https://www.paypal.com/cgi-bin/webscr" method="post">

<input type="hidden" name="cmd" value="_cart">

<input type="hidden" name="upload" value="1">

<input type="hidden" name="business" value="

you still don't seem to be setting any content-type in the mail header.

 

also, unless $_POST[message'] contains the standard <html><head><body> tag layout as well as your array data, you are also still not building the page properly.

 

Please use code tags when posting code in the forum, and try to avaid linking to files as most people will not follow links from stangers.

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.