Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Sep 2005
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Email completed order form in HTML format

    Shopping Cart workflow;
    Once the order and customer info is entered, the viewer goes to a confirmation page. If everything looks fine, they hit the submit. The order is added to the database an email is sent to the customer showing the order has been submitted and the email includes a customer order number.

    I would like to have the final confirmation page to send an email formatted in html. So the customer and the order desk get the completed order form as it looked in the browser window. Is this possible and how easy is it (new to php)

    Cheers Rick

    <?php
    /*
    Line 1 : Make sure this file is included instead of requested directly
    Line 2 : Check if step is defined and the value is two
    Line 3 : The POST request must come from this page but the value of step is one
    */
    if (!defined('WEB_ROOT')
    || !isset($_GET['step']) || (int)$_GET['step'] != 2
    || $_SERVER['HTTP_REFERER'] != 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'] . '?step=1') {
    exit;
    }

    /*
    Make sure all the required field exist is $_POST and the value is not empty
    Note: txtShippingAddress2 and txtPaymentAddress2 are optional
    */
    $requiredField = array('txtShippingFirstName', 'txtShippingLastName', 'txtShippingAddress1', 'txtShippingCity', 'txtShippingPostalCode',
    'txtPaymentFirstName', 'txtPaymentLastName', 'txtPaymentAddress1', 'txtPaymentCity', 'txtPaymentPostalCode');

    if (!checkRequiredPost($requiredField)) {
    echo 'Input not complete';
    }

    $errorMessage = '&nbsp;';
    $cartContent = getCartContent();

    ?>
    <table width="550" border="0" align="center" cellpadding="10" cellspacing="0">
    <tr>
    <td>Step 2 Of 2 : Confirm Order </td>
    </tr>
    </table>
    <p id="errorMessage"><?php echo $errorMessage; ?></p>
    <form action="<?php echo $_SERVER['PHP_SELF']; ?>?step=3" method="post" name="frmCheckout" id="frmCheckout">
    <table width="550" border="0" align="center" cellpadding="5" cellspacing="1" class="infoTable">
    <tr class="infoTableHeader">
    <td colspan="3">Ordered Item</td>
    </tr>
    <tr class="label">
    <td>Item</td>
    <td>Unit Price</td>
    <td>Total</td>
    </tr>
    <?php
    $numItem = count($cartContent);
    $subTotal = 0;
    for ($i = 0; $i < $numItem; $i++) {
    extract($cartContent[$i]);
    $subTotal += $pd_price * $ct_qty;
    ?>
    <tr class="content">
    <td class="content"><?php echo "$ct_qty x $pd_name"; ?></td>
    <td align="right"><?php echo displayAmount($pd_price); ?></td>
    <td align="right"><?php echo displayAmount($ct_qty * $pd_price); ?></td>
    </tr>
    <?php
    }
    ?>
    <tr class="content">
    <td colspan="2" align="right">Total</td>
    <td align="right"><?php echo displayAmount($ct_qty * $pd_price); ?></td>
    </tr>
    </table>
    <p>&nbsp;</p>
    <table width="550" border="0" align="center" cellpadding="5" cellspacing="1" class="infoTable">
    <tr class="infoTableHeader">
    <td colspan="2">Shipping Information</td>
    </tr>
    <tr>
    <td width="150" class="label">First Name</td>
    <td class="content"><?php echo $_POST['txtShippingFirstName']; ?><input name="hidShippingFirstName" type="hidden" id="hidShippingFirstName" value="<?php echo $_POST['txtShippingFirstName']; ?>"></td>
    </tr>
    <tr>
    <td width="150" class="label">Last Name</td>
    <td class="content"><?php echo $_POST['txtShippingLastName']; ?><input name="hidShippingLastName" type="hidden" id="hidShippingLastName" value="<?php echo $_POST['txtShippingLastName']; ?>"></td>
    </tr>
    <tr>
    <td width="150" class="label">Address1</td>
    <td class="content"><?php echo $_POST['txtShippingAddress1']; ?><input name="hidShippingAddress1" type="hidden" id="hidShippingAddress1" value="<?php echo $_POST['txtShippingAddress1']; ?>"></td>
    </tr>
    <tr>
    <td width="150" class="label">Address2</td>
    <td class="content"><?php echo $_POST['txtShippingAddress2']; ?><input name="hidShippingAddress2" type="hidden" id="hidShippingAddress2" value="<?php echo $_POST['txtShippingAddress2']; ?>"></td>
    </tr>
    <tr>
    <td width="150" class="label">City</td>
    <td class="content"><?php echo $_POST['txtShippingCity']; ?><input name="hidShippingCity" type="hidden" id="hidShippingCity" value="<?php echo $_POST['txtShippingCity']; ?>" ></td>
    </tr>
    <tr>
    <td width="150" class="label">Province</td>
    <td class="content"><?php echo $_POST['txtShippingProvince']; ?><input name="hidShippingProvince" type="hidden" id="hidShippingProvince" value="<?php echo $_POST['txtShippingProvince']; ?>" ></td>
    </tr>
    <tr>
    <td width="150" class="label">Postal Code</td>
    <td class="content"><?php echo $_POST['txtShippingPostalCode']; ?><input name="hidShippingPostalCode" type="hidden" id="hidShippingPostalCode" value="<?php echo $_POST['txtShippingPostalCode']; ?>"></td>
    </tr>
    <tr>
    <td width="150" class="label">Email Address</td>
    <td class="content"><?php echo $_POST['txtShippingEmail']; ?><input name="hidShippingEmail" type="hidden" id="hidShippingEmail" value="<?php echo $_POST['txtShippingEmail']; ?>"></td>
    </tr>
    </table>
    <p>&nbsp;</p>
    <table width="550" border="0" align="center" cellpadding="5" cellspacing="1" class="infoTable">
    <tr class="infoTableHeader">
    <td colspan="2">Payment Information</td>
    </tr>
    <tr>
    <td width="150" class="label">First Name</td>
    <td class="content"><?php echo $_POST['txtPaymentFirstName']; ?><input name="hidPaymentFirstName" type="hidden" id="hidPaymentFirstName" value="<?php echo $_POST['txtPaymentFirstName']; ?>"></td>
    </tr>
    <tr>
    <td width="150" class="label">Last Name</td>
    <td class="content"><?php echo $_POST['txtPaymentLastName']; ?><input name="hidPaymentLastName" type="hidden" id="hidPaymentLastName" value="<?php echo $_POST['txtPaymentLastName']; ?>"></td>
    </tr>
    <tr>
    <td width="150" class="label">Address1</td>
    <td class="content"><?php echo $_POST['txtPaymentAddress1']; ?><input name="hidPaymentAddress1" type="hidden" id="hidPaymentAddress1" value="<?php echo $_POST['txtPaymentAddress1']; ?>"></td>
    </tr>
    <tr>
    <td width="150" class="label">Address2</td>
    <td class="content"><?php echo $_POST['txtPaymentAddress2']; ?>
    <input name="hidPaymentAddress2" type="hidden" id="hidPaymentAddress2" value="<?php echo $_POST['txtPaymentAddress2']; ?>">
    </td>
    </tr>
    <tr>
    <td width="150" class="label">City</td>
    <td class="content"><?php echo $_POST['txtPaymentCity']; ?><input name="hidPaymentCity" type="hidden" id="hidPaymentCity" value="<?php echo $_POST['txtPaymentCity']; ?>"></td>
    </tr>
    <tr>
    <td width="150" class="label">Province</td>
    <td class="content"><?php echo $_POST['txtPaymentProvince']; ?><input name="hidPaymentProvince" type="hidden" id="hidPaymentProvince" value="<?php echo $_POST['txtPaymentProvince']; ?>"></td>
    </tr>
    <tr>
    <td width="150" class="label">Postal Code</td>
    <td class="content"><?php echo $_POST['txtPaymentPostalCode']; ?><input name="hidPaymentPostalCode" type="hidden" id="hidPaymentPostalCode" value="<?php echo $_POST['txtPaymentPostalCode']; ?>"></td>
    </tr>
    <tr>
    <td width="150" class="label">Email Address</td>
    <td class="content"><?php echo $_POST['txtPaymentEmail']; ?><input name="hidPaymentEmail" type="hidden" id="hidPaymentEmail" value="<?php echo $_POST['txtPaymentEmail']; ?>"></td>
    </tr>
    </table>
    <p align="center">
    <input name="btnBack" type="button" id="btnBack" value="&lt;&lt; Modify Shipping/Payment Info" onClick="window.location.href='checkout.php?step=1';" class="box">
    &nbsp;&nbsp;
    <input name="btnConfirm" type="submit" id="btnConfirm" value="Confirm Order &gt;&gt;" class="box">
    </form>
    Last edited by norton73; 09-13-2005 at 11:20 PM.

  • #2
    Regular Coder
    Join Date
    Jun 2004
    Posts
    194
    Thanks
    5
    Thanked 0 Times in 0 Posts
    This should give you a basic idea:

    PHP Code:
    <?php

    // check all required info has been provided by user
    if ($AllRequiredInfoProvided) {

        
    // setup the email values
        
    $to "yourname@yoursite.com";
        
    $subject "Customer Order";
        
    $from "whatever@whereever.com";

        
    // add the mail headers. header MUST end with \r\n as these do
        
    $headers "From: " $from "\r\n";
        
    $headers .= "MIME-Version: 1.0\r\n"
        
    $headers .= "Content-type: text/html; charset=iso-8859-1\r\n";

        
    $msg .= "<body style=\"margin: 5px; font-family: Tahoma, Helvetica, Sans-Serif; font-size: 8pt;\">\n";

        
    // add all your order info here. Example:
        
    $msg .= "<p><strong>Name:</strong> " $_POST['name'] . "</p>\n";
        
    $msg .= "<p><strong>Order No:</strong> " $_POST['orderno'] . "</p>\n";

        
    // remember each $msg line must have a dot before the equals
        
    $msg .= "</body>";

        
    // send the mail
        
    mail($to$subjectstripslashes($msg), $headers) or die("<p class=\"center\"><strong class=\"red\">ERROR:</strong> Unable To Connect To SMTP Server</p>\n");

        
    // give successfully sent message
        
    echo "<p class=\"center\"><strong class=\"green\">Thank You. Your Order Has Been Processed.</strong></p>\n";

    // not all require info provided
    } else {
        
    // give not all info provided error and stop any further actions
        
    echo "<p class=\"center\"><strong class=\"red\">ERROR:</strong> You Have Not Provided All The Required Information.</p>\n";
        return 
    false;

    }

    ?>


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •