How can i fix this? I have a form that outputs all this data but I want it sent in one email. The message of the email should include $First, $Last, $email, $phone, $request, $order and comments. Any help would be appreciated... <? $memail = "myemail@email.com"; $subject = $_POST["subject"]; $recipient = $_POST["recipient"]; $redirect = $_POST["redirect"]; $missing= $_POST['missing_fields_redirect']; $First = $_POST["First"]; $Last = $_POST["Last"]; $email = $_POST["email"]; $phone = $_POST["phone"]; $request = $_POST["Request"]; $order = $_POST["Order Number"]; $comments = $_POST["comments"]; if ($First =='' || $Last=='' || $email=='' || $request=='' || $comments==''){ echo "Please fill in the required fields."; }else{ mail( "$memail", "$subject", $comments, "From: $email" ); } ?> PHP:
<? $memail = "myemail@email.com"; $subject = $_POST["subject"]; $recipient = $_POST["recipient"]; $redirect = $_POST["redirect"]; $missing= $_POST['missing_fields_redirect']; $First = $_POST["First"]; $Last = $_POST["Last"]; $email = $_POST["email"]; $phone = $_POST["phone"]; $request = $_POST["Request"]; $order = $_POST["Order Number"]; $comments = $_POST["comments"]; if ($First =='' || $Last=='' || $email=='' || $request=='' || $comments==''){ echo "Please fill in the required fields."; }else{ $comments = "First: $First\nLast: $Last\nEmail: $email...(and so on)\n\n$comments"; mail( "$memail", "$subject", $comments, "From: $email" ); } ?> PHP:
If formatting isn't of the highest priority, you could use this: <?php function print_array_nodes( $TheArray ) { echo "<table border=1>\n"; $Keys = array_keys( $TheArray ); foreach( $Keys as $OneKey ) { echo "<tr>\n"; echo "<td bgcolor='#727450'>"; echo "<B>" . $OneKey . "</B>"; echo "</td>\n"; echo "<td bgcolor='#C4C2A6'>"; if ( is_array($TheArray[$OneKey]) ) print_array_nodes($TheArray[$OneKey]); else echo $TheArray[$OneKey]; echo "</td>\n"; echo "</tr>\n"; } echo "</table>\n"; } $memail = "myemail@email.com"; $subject = $_POST["subject"]; $recipient = $_POST["recipient"]; $redirect = $_POST["redirect"]; $missing= $_POST['missing_fields_redirect']; $First = $_POST["First"]; $Last = $_POST["Last"]; $email = $_POST["email"]; $phone = $_POST["phone"]; $request = $_POST["Request"]; $order = $_POST["Order Number"]; $comments = $_POST["comments"]; if ($First =='' || $Last=='' || $email=='' || $request=='' || $comments==''){ echo "Please fill in the required fields."; } else { //STORE OUTPUT ob_start(); //TRANSLATE ARRAY INTO TABLE print_array_nodes($_POST); //ASSIGN DATA TO A VARIABLE $data = ob_get_contents() ; //REMOVE EXTRA LINE BREAKS / NEW LINES $data = ereg_replace("\r","",$data); $data = ereg_replace("\n","",$data); //CLEAN OUT THE OUTPUT BUFFER ob_clean(); $headers = 'MIME-Version: 1.0' . "\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\n"; //SEND THE MESSAGE mail("$memail","$subject",$data,$headers); } ?> PHP: This will allow you to add more information to your form post and not worry about including it into the email message. -Bing