Thanks for your help guys.
I was wondering if I posted the code I have, if you could possibly let me know if I am on the right lines ?
The Javascript that calculates the totals is below:
<tr>
<td colspan="6" style="text-align: right;">Product Subtotal: <input type="text" class="total-box" value="£0" id="product-subtotal" disabled="disabled"></td>
</tr>
</table>
<div id="totals">
<!-- <div class="clear"></div>-->
<!-- <div style="text-align: right;">-->
<span>ORDER TOTAL: </span>
<input type="text" class="total-box" value="£0" id="order-total" disabled="disabled"></div>
<br />
<form class="mailOrder" action="mail_order.php" method="post" accept-charset="utf-8" id="mail-order-form">
<input type="hidden" name="name" value="Multi Product Order" />
<input type="hidden" id="fc-price" name="price" value="0" />
<input type="submit" value="Submit Order" class="submit" />
</form>
</div>
<div id="shiptable">
<table id="shipping-table">
<tr>
<!-- <th>Total Qty.</th>-->
<th>Shipping Rate</th>
<th style="text-align: right;">Shipping Total</th>
</tr>
<tr>
<!-- <td id="total-pallets"><input id="total-pallets-input" value="0" type="text" disabled="disabled"></td>-->
<td id="shipping-rate">0.00</td>
<td style="text-align: right;"><input type="text" class="total-box" value="£0" id="shipping-subtotal" disabled="disabled"></td>
</tr>
</table></div>
And of course the php:
<?php
// This function checks for email injection. Specifically, it checks for carriage returns - typically used by spammers to inject a CC list.
function isInjected($str) {
$injections = array('(\n+)',
'(\r+)',
'(\t+)',
'(%0A+)',
'(%0D+)',
'(%08+)',
'(%09+)'
);
$inject = join('|', $injections);
$inject = "/$inject/i";
if(preg_match($inject,$str)) {
return true;
}
else {
return false;
}
}
// Load form field data into variables.
$order_total = $_REQUEST['order-total'] ;
$product_subtotal = $_REQUEST['product-subtotal'] ;
// If the user tries to access this script directly, redirect them to feedback form,
if (!isset($_REQUEST['order-total'])) {
header( "Location: feedback_form.php" );
}
// If the form fields are empty, redirect to the error page.
elseif (empty($order_total) || empty($product_subtotal)) {
header( "Location: error_message.php" );
}
// If email injection is detected, redirect to the error page.
elseif ( isInjected($email_address) ) {
header( "Location: error_message.html" );
}
// If we passed all previous tests, send the email!
else {
mail( "
[email protected]", "Feedback Form Results",
$order_total, "From: $email_address" );
header( "Location: thank_you.php" );
}
?>
Any further pointers on this would be greatly appreciated. I am still learning as I go.
Thanks in advance.