denoteone Posted March 30, 2010 Share Posted March 30, 2010 I need to add a whole bunch of variables to one variable and then send that variable in a email. But my page keeps breaking. I have an array for the titles of the product and an array from my my form with price values. $txt = ''.$products2[0] .': '.$_POST[$products2[0]].'<br/> '.$products2[1] .': '.$_POST[$products2[1]].'<br/> '.$products2[2] .': '.$_POST[$products2[2]].'<br/> '.$products2[3] .': '.$_POST[$products2[3]].'<br/> '.$products2[4] .': '.$_POST[$products2[4]].'<br/> '.$products2[5] .': '.$_POST[$products2[5]].'<br/> '.$products2[6] .': '.$_POST[$products2[6]].'<br/> '.$products2[7] .': '.$_POST[$products2[7]].'<br/> '.$products2[8] .': '.$_POST[$products2[8]].'<br/> '.$products2[9] .': '.$_POST[$products2[9]].'<br/> '.$products2[10] .': '.$_POST[$products2[10]].'<br/> '.$products2[11] .': '.$_POST[$products2[11]].'<br/> '.$products2[12] .': '.$_POST[$products2[12]].'<br/> '.$products2[13] .': '.$_POST[$products2[13]].'<br/> '.$products2[14] .': '.$_POST[$products2[14]].'<br/> '.$products2[15] .': '.$_POST[$products2[15]].'<br/> '.$products2[16] .': '.$_POST[$products2[16]].'<br/> '.$products2[17] .': '.$_POST[$products2[17]].'<br/> '.$products2[18] .': '.$_POST[$products2[18]].'<br/> '.$products2[19] .': '.$_POST[$products2[19]].'<br/> '.$products2[20] .': '.$_POST[$products2[20]].'<br/> '.$products2[21] .': '.$_POST[$products2[21]].'<br/> '.$products2[22] .': '.$_POST[$products2[22]].'<br/> '.$products2[23] .': '.$_POST[$products2[23]].'<br/> '.$products2[24] .': '.$_POST[$products2[24]].'<br/> '.$products2[25] .': '.$_POST[$products2[25]].'<br/> '.$products2[26] .': '.$_POST[$products2[26]].'<br/> '.$products2[27] .': '.$_POST[$products2[27]].'<br/> '.$products2[28] .': '.$_POST[$products2[28]].'<br/> '.$products2[29] .': '.$_POST[$products2[29]].'<br/>''; $headers = "From:Product Prices" . "\r\n" . "CC: [email protected]"; mail($to,$subject,$txt,$headers); Quote Link to comment https://forums.phpfreaks.com/topic/196942-mail-function-content-issue/ Share on other sites More sharing options...
gilgimech Posted March 30, 2010 Share Posted March 30, 2010 This is how I would do it. You would want to make each of the '.$products2[0] .': '.$_POST[$products2[0]].' into separate variables. $product_0 = '.$products2[0] .': '.$_POST[$products2[0]].'; etc. Then change $txt to $message. When you build the $message variables you want it in this format: $message = $product_0n\$product_1n\etc. From what I understand the mail() function can only accept certain variables and you cannot use <br/> you have to use n\. There may be a better way of doing it but that's the way I know how. Quote Link to comment https://forums.phpfreaks.com/topic/196942-mail-function-content-issue/#findComment-1033920 Share on other sites More sharing options...
oni-kun Posted March 30, 2010 Share Posted March 30, 2010 Don't you mean \n? Quote Link to comment https://forums.phpfreaks.com/topic/196942-mail-function-content-issue/#findComment-1033928 Share on other sites More sharing options...
gilgimech Posted March 30, 2010 Share Posted March 30, 2010 Right \n, been a long day. typo, sorry will edit. Quote Link to comment https://forums.phpfreaks.com/topic/196942-mail-function-content-issue/#findComment-1033930 Share on other sites More sharing options...
oni-kun Posted March 30, 2010 Share Posted March 30, 2010 Just note a Windows system will require \r\n, And as well it has to be within double quotes to parse "\n" else it won't escape into the character @ OP. Quote Link to comment https://forums.phpfreaks.com/topic/196942-mail-function-content-issue/#findComment-1033937 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.