Hi Guys,
I have designed an online sales order form which I am now at the stage where the user can enter information & hit the submit button & get the results emailed to my email address.
However, there are two slight problems I need to resolve.
The first is that when the submit button is clicked on I receive two copies of the email (results).
The second is that when the results come through via email there are no line breaks between each field which is where I though the "/n/n" command came in of which I have put at the end of each message variable in the build message section as you will see.
The PHP script is shown below along with the form and as you will see I have implemented PHPMailer.
<?php
include('includes/title.inc.php');
include('includes/corefuncs.inc.php');
if (function_exists('nukeMagicQuotes')) {
nukeMagicQuotes();
}
//process the email
if (array_key_exists('submit_form', $_POST)) {
//process the $POST variables
$account_no = $POST['account_no'];
$pages = $POST['pages'];
$order_no = $POST['order_no'];
$date = $POST['date'];
$payment_method = $POST['payment_method'];
$order_taken_by = $POST['order_taken_by'];
$account_name = $POST['account_name'];
$company_name = $POST['company_name'];
$account_address = $POST['account_address'];
$delivery_address = $POST['delivery_address'];
$dealer_contact_name = $POST['dealer_contact_name'];
$end_user_contact_name = $POST['end_user_contact_name'];
$dealer_telephone_no = $POST['dealer_telephone_no'];
$end_user_telephone_no = $POST['end_user_telephone_no'];
$trust_stock_code_one = $POST['trust_stock_code_one'];
$supplier_stock_code_one = $POST['supplier_stock_code_one'];
$product_description_one = $POST['product_description_one'];
$product_colour_one = $POST['product_colour_one'];
$product_quantity_one = $POST['product_quantity_one'];
$trust_stock_code_two = $POST['trust_stock_code_two'];
$supplier_stock_code_two = $POST['supplier_stock_code_two'];
$product_description_two = $POST['product_description_two'];
$product_colour_two = $POST['product_colour_two'];
$product_quantity_two = $POST['product_quantity_two'];
$trust_stock_code_three = $POST['trust_stock_code_three'];
$supplier_stock_code_three = $POST['supplier_stock_code_three'];
$product_description_three = $POST['product_description_three'];
$product_colour_three = $POST['product_colour_three'];
$product_quantity_three = $POST['product_quantity_three'];
$trust_stock_code_four = $POST['trust_stock_code_four'];
$supplier_stock_code_four = $POST['supplier_stock_code_four'];
$product_description_four = $POST['product_description_four'];
$product_colour_four = $POST['product_colour_four'];
$product_quantity_four = $POST['product_quantity_four'];
$trust_stock_code_five = $POST['trust_stock_code_five'];
$supplier_stock_code_five = $POST['supplier_stock_code_five'];
$product_description_five = $POST['product_description_five'];
$product_colour_five = $POST['product_colour_five'];
$product_quantity_five = $POST['product_quantity_five'];
$delivery_service = $POST['delivery_service'];
$special_instructions = $POST['special_instructions'];
//build the message
$message = "Account no: $account_no\n\n";
$message .= "No of pages: $pages\n\n";
$message .= "Order No: $order_no\n\n";
$message .= "Date: $date\n\n";
$message .= "Payment method: $payment_method\n\n";
$message .= "Order taken by: $order_taken_by\n\n";
$message .= "Account name: $account_name\n\n";
$message .= "Company name: $company_name\n\n";
$message .= "Account address: $account_address\n\n";
$message .= "Delivery address: $delivery_address\n\n";
$message .= "Dealer contact name: $dealer_contact_name\n\n";
$message .= "End user contact name: $end_user_contact_name\n\n";
$message .= "Dealer telephone no: $dealer_telephone_no\n\n";
$message .= "End user telephone no: $end_user_telephone_no\n\n";
$message .= "(1) Trust stock code: $trust_stock_code_one\n\n";
$message .= "(1) Supplier stock code: $supplier_stock_code_one\n\n";
$message .= "(1) Product description: $product_description_one\n\n";
$message .= "(1) Product colour: $product_colour_one\n\n";
$message .= "(1) Product quantity: $product_quantity_one\n\n";
$message .= "(2) Trust stock code: $trust_stock_code_two\n\n";
$message .= "(2) Supplier stock code: $supplier_stock_code_two\n\n";
$message .= "(2) Product description: $product_description_two\n\n";
$message .= "(2) Product colour: $product_colour_two\n\n";
$message .= "(2) Product quantity: $product_quantity_two\n\n";
$message .= "(3) Trust stock code: $trust_stock_code_three\n\n";
$message .= "(3) Supplier stock code: $supplier_stock_code_three\n\n";
$message .= "(3) Product description: $product_description_three\n\n";
$message .= "(3) Product colour: $product_colour_three\n\n";
$message .= "(3) Product quantity: $product_quantity_three\n\n";
$message .= "(4) Trust stock code: $trust_stock_code_four\n\n";
$message .= "(4) Supplier stock code: $supplier_stock_code_four\n\n";
$message .= "(4) Product description: $product_description_four\n\n";
$message .= "(4) Product colour: $product_colour_four\n\n";
$message .= "(4) Product quantity: $product_quantity_four\n\n";
$message .= "(5) Trust stock code: $trust_stock_code_five\n\n";
$message .= "(5) Supplier stock code: $supplier_stock_code_five\n\n";
$message .= "(5) Product description: $product_description_five\n\n";
$message .= "(5) Product colour: $product_colour_five\n\n";
$message .= "(5) Product quantity: $product_quantity_five\n\n";
$message .= "Service required: $delivery_service\n\n";
$message .= "Special instructions: $special_instructions";
//limit line length to 70 characters
$message = wordwrap($message, 70);
//send it
require('class.phpmailer.php');
$mail = new PHPMailer();
$mail->SetLanguage('en', '/phpmailer/language/phpmailer.lang-en.php');
$mail->IsSMTP();
$mail->Host = "hostl.internet.com";
$mail->SMTPAuth = true;
$mail->Username = "myemail@address.com";
$mail->Password = "password";
$mail->From = "myemail@address.com";
$mail->FromName = "Sales";
$mail->AddAddress("myemail@address.com");
$mail->IsHTML(true);
$mail->Subject = "Sales Order Form";
$mail->Body = $message;
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>Trust Distribution Intranet<?php echo "—($title)"; ?></title>
<link rel="stylesheet" type="text/css" href="trust intranet.css" />
</head>
<body>
<?php include('includes/header.inc.php'); ?>
<?php include('includes/menu.inc.php'); ?>
<?php
if ($_POST && !$mail->Send())
{
echo "Message could not be sent. <p>";
echo "Mailer Error: " . $mail->ErrorInfo;
exit;
}
elseif ($_POST && $mail->send())
{
echo "Message has been sent";
}
?>[/B]
If you need anymore info let me know.
Any advice would be appreciated.