I'm working on an order form that needs to email the form data back to me and a copy to the customer. I've looked all over these forums at other simular posts and I think I have it, I just need to know if I'm on the right track.
By way of explaination, my form is dynamically created. The user enters the amount of items they want to order and submit. The next page shows fields for Qty, Part Number and Description. If the user entered 5 on the first page, he'd have 5 rows of fields to fill in. I have the form working where it prints out every thing to the browser .
Will the following code work for me to email what has printed to the browser?
if (isset($_POST['order']) && is_array($_POST['qty']) && is_array($_POST['partnum']) && is_array($_POST['desc'])) {
// Get post variables
$custno = $_POST['custno'];
$customer = $_POST['customer'];
$street = $_POST['street'];
$city = $_POST['city'];
$state = $_POST['state'];
$zip = $_POST['zip'];
$phone = $_POST['phone'];
$poc = $_POST['poc'];
$pocemail = $_POST['pocemail'];
$email = $_POST['email'];
$qty = $_POST['qty'];
$partnum = $_POST['partnum'];
$desc = $_POST['desc'];
$arraycount = 0;
$sendto = "$pocemail";
$bcc = "me@domain.tld";
$subject = "Company Online Order";
$message = "Your Online Order has been sent, here's what you ordered: \r\n$poc \r\n$pocemail \r\n\r\n$custno \r\n$customer \r\n$street \r\n$city, $state, $zip \r\n$phone \r\n$email \r\n\r\nPO Number: $ponumber \r\nShipping Methood: $shipping \r\nComments: $comment \r\n\r\n
Item Qty Part# Description\r\n";
for ($lines = 1; ($lines <= $_POST['items']); $lines++) {
$message .="$lines $qty[$arraycount] $partnum[$arraycount] $desc[$arraycount]\r\n";
$arraycount++;
}
$message = wordwrap($message, 80);
$headers = 'From: customerservice@domain.tld' ."\r\n" . 'Reply-To: customerservice@domain.tld' . "\r\n" . 'X-Mailer: PHP/' . phpversion();
mail($sendto, $subject, $message, $headers);
?>
//Print the above to browser
In this thread the $message variable is shown as
$message = "A message";
$message .="More message";
$message .="Even more message";
Will this work in my for statement to print the array into the message?