Hi guys. As I have said in my earlier posts, I am new to PHP. Still feeling my way through. I have a script that takes information from a form and places it into a mysql database. This same script sends some of the information to an email address that I specify and it also sends an order confirmation to the customer's email address. I am trying to find out how to remove some of the information in two of the values so that I may add those two values and display a total in those emails. An example of those two possible values is listed below.

<input class=mainForm type=radio name=field_4 id=field_4_option_1 value="8x10 +$39.00 each" />

and

<input class=mainForm type=radio name=field_9 id=field_9_option_1 value="Convert image to Sepia Tone +$9.95" />

Here is the code that I am trying to insert the data into. I need the information to be placed in the section labled total....

$busmail = $_POST['field_2'];

mail($busmail, "Order Confirmation","Your Order Has Been Received And Is Now Being Processed.

 
Quantity: " . $_POST['field_3'] . " 
Size: " . $_POST['field_4'] . " 
Special Instructions: " . $_POST['field_5'] . " 
Total: " . $_POST['

Please contact us with any questions or concerns at c2c@capturedtocanvas.com
");

Any help here would be great! Thanks in advance..

Explode the value on +. Then add the required fields.
Eg.

$value1 = $_POST['field1'];
//consider $value1 has 100+xyz
$value2 = $_POST['field2'];
//$value2 = 300+abc
$newval1 = explode("+",$value1);
$newval2 = explode("+",$value2);
//$newval1 and $newval2 will be an array where $newval1[0] will have 100, $newval1[1] will have xyz and $newval2[0] will have 300, $newval2[1] will have the value abc. 
$total = $newval1[0] + $newval2[0];
echo $total; // 100+300 = 400
?>

Hope that helps :)

This article has been dead for over six months. Start a new discussion instead.