php: long variables with other variables which needs to be sent by email

Joined
12 Feb 2006
Posts
17,605
Location
Surrey
i'm trying to make a nice looking email for when someone submits a quote. currently it's sent in plain text but i'd like to make it in html and add some very basic css.

i've got the email designed fine, however i'm struggling to fill the info with the unique data that the user would have input.

at the moment when the user fills out a form and it gets sent to them it's sent like this...

PHP:
if($job1>0) { $body .= "job1: <b>$job1</b>"; }
if($job2>0) { $body .= "job2: <b>$job2</b>"; }
if($job3>0) { $body .= "job3: <b>$job3</b>"; }

mail($your_email, "subject here", $body);

etc

and when the user fills out the form they're shown the form online like this (though this is only tiny part of the form it's much busier/longer then this)

PHP:
<?php if ($service == "theonewewent") { ?>
<tr>
<td><i>this is the service you selected</i></td>
<td></td>
<td><i>Free</i></td>
</tr>
<?php } ?>


<tr>
<td colspan='3' class='newLine'><hr /></td>
</tr>

<tr class='finalArea'>
<td colspan='2'>Sub Total:</td>
<td>&pound;<?= $quote_subtotal; ?></td>
</tr>
<tr class='finalArea <?php if ($discount_total>0) { echo " discountStyle "; } ?>'>
<td colspan='2'> Total Discount:</td>
<td>&pound;<?= $discount_total; ?> </td>
</tr>
<tr class='finalArea totalPrice'>
<td colspan='2'>Total Price:</td>
<td>&pound;<?= $quote_total; ?></td>
</tr>

what i am hoping to do is be able to save what the user sees online under 1 long variable, and then get this sent like the $body is sent by email. the trboule i'm having is understanding how i'll get what is shown online into one variable as there is so much code already.

it may be that i need to restart and simplify the whole thing so i'm open to suggestions on what is the best way for this.
 
Back
Top Bottom