I have a very long HTML form, processed using PHP. I have been asked to combine some fields in the email output of the form.
I'm using $Field to pick up everything, inc name, email, etc. The ordering section of the form uses two fields for each item, a text input quantity (e.g. q_itemone) and an item spec taken from a dropdown (e.g. s_itemone).
The email currently gets sent reading (for example)...
q_itemone: 88
s_itemone: large
How might I (Can I?) get my email to combine these two fields, so that the output reads (for example)
itemone: 88 x large
Code snippet below. Any advice much appreciated - thanks.
Code: Select all
<?php
$to='Name <name@email.uk>';
$messageSubject="Quote";
$confirmationSubject="Quote";
$confirmationBody="Thank you ". $Name . " for visiting Name. \n\nYou have asked us to quote for the following items:\n\n". $MsgBody . "\n";
$displayForm=true;
if ($_POST){
$SubmissionName=stripslashes($_POST['Name']);
$Email=stripslashes($_POST['Email']);
foreach
($_POST as $Field=>$value)
if (is_array($value)){
$MsgBody .= "$Field:".implode(", " , $value)."\n\n";
}
else {
if(strlen($value[$z])>0)
$MsgBody .= "$Field: $value\n\n";
}
$valid=eregi('^([0-9a-z]+[-._+&])*[0-9a-z]+@([-0-9a-z]+[.])+[a-z]{2,6}$',$Email);
if ($Email && $valid){
if (mail($to,$messageSubject,$MsgBody,'From: '.$Email."\r\n")
&& mail($Email,$confirmationSubject,$confirmationBody.$MsgBody,'From: '.$to."\r\n")){
$displayForm=false;
?>