I'm really hoping someone can help me. I've been trying to do this for some time. I have an HTML order form with multiple text fields into which numbers are entered to indicate how many of the selected product is desired.
That form posts to PHP file which sends an email to the owner, an autoresponder, and generates an HTML Thank you page.
When the owner gets the email it lists all variables (text fields) with the corresponding data (amount ordered). IF none was entered there si a blank space next to the item. What I need is that same list generated to the HTML thank yo upage but omitting any variable with no data attached so that it only shows the items selected.
Also, the confirmation page should not include the contact and delivery information.
Can someone help me tweak my sample code below?
<?php
# ----------------------------------------------------
# -----
# ----- This script was generated by PHP-Form Wizard 1.2.5 on 4/1/2008 at 9:20:11 Miller Time
# -----
# ----- http://www.tools4php.com
# -----
# ----------------------------------------------------
// Receiving variables
$chocolate = addslashes($_POST['chocolate']);
$double_chocolate = addslashes($_POST['double_chocolate']);
$strawberry = addslashes($_POST['strawberry']);
$peach = addslashes($_POST['peach']);
$cherry = addslashes($_POST['cherry']);
$apricot = addslashes($_POST['apricot']);
$tropical_fruit_punch = addslashes($_POST['tropical_fruit_punch']);
$Delivery_Options = addslashes($_POST['Delivery_Options']);
$name_of_person_placing_order = addslashes($_POST['name_of_person_placing_order']);
$phone_number = addslashes($_POST['phone_number']);
$email_address = addslashes($_POST['email_address']);
$delivery_month = addslashes($_POST['delivery_month']);
$delivery_day = addslashes($_POST['delivery_day']);
$delivery_year = addslashes($_POST['delivery_year']);
$delivery_hour = addslashes($_POST['delivery_hour']);
$delivery_minute = addslashes($_POST['delivery_minute']);
$am_pm = addslashes($_POST['am_pm']);
$street_address_1 = addslashes($_POST['street_address_1']);
$street_address_2 = addslashes($_POST['street_address_2']);
$city = addslashes($_POST['city']);
$state = addslashes($_POST['state']);
$zip_code = addslashes($_POST['zip_code']);
$comment = addslashes($_POST['comment']);
// Validation
//Sending Email to form owner
$pfw_header = "From: $email_address\n"
. "Reply-To: $email_address\n";
$pfw_subject = "Your Order";
$pfw_email_to = "myemail@yahoo.com";
$order = "Chocolate: $chocolate\n"
. "Double Chocolate: $double_chocolate\n"
. "Strawberry: $strawberry\n"
. "Peach: $peach\n"
. "Cherry: $cherry\n"
. "Apricot: $apricot\n"
. "Tropical Fruit Punch: $tropical_fruit_punch\n"
. "Delivery Options: $Delivery_Options\n"
. "Name of Person Placing Order: $name_of_person_placing_order\n"
. "Phone Number: $phone_number\n"
. "Email Address: $email_address\n"
. "Delivery Month: $delivery_month\n"
. "Delivery Day: $delivery_day\n"
. "Delivery Year: $delivery_year\n"
. "Delivery Hour: $delivery_hour\n"
. "Delivery Minute: $delivery_minute\n"
. "Am/Pm: $am_pm\n"
. "Street Address 1: $street_address_1\n"
. "Street Address 2: $street_address_2\n"
. "City: $city\n"
. "State: $state\n"
. "Zip Code: $zip_code\n"
. "Comment: $comment\n";
mail($pfw_email_to, $pfw_subject ,$order ,$pfw_header ) ;
//Sending auto respond Email to visitor
$pfw_header = "From: info@yahoo.com\n"
. "Reply-To: info@yahoo.com\n";
$pfw_subject = "Order Confirmation";
$pfw_email_to = "$email_address";
$pfw_message = "This is a courtesy confirmation of the order you recently placed on the website. There is no need to respond to this email.\n"
. "\n"
. "Should any alterations need to be made, please call us as soon as possible at 312-333-3333 and a representative will be more than happy to assist you.\n"
. "\n"
. "Thank you again for your business.\n"
. "\n"
. "\n"
. "$order";
mail($pfw_email_to, $pfw_subject ,$pfw_message ,$pfw_header) ;
/* Results render as HTML */
$results = <<<EOD
<html>
<head>
<title>Order Confirmation</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
<!--
body {
background-color: #9ed8eb;
font-family:Geneva, Arial, Helvetica, sans-serif;
font-size: 14px;
font-style: normal;
line-height: normal;
font-weight: normal;
color: #4a2300;
text-decoration: none;
}
-->
</style>
</head>
<div>
<div align="center" style="font-weight: bold; font-size: large;">Thank you for your order!<br> A confirmation email will arrive momentarily in the email address inbox you provided in the order form.<br><br><a href="http://www.mysite.com"> Return To <br />
website</a></div>
</div>
</body>
</html>
EOD;
echo "$results";
?>