Email submission with maths

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
apg1985
Forum Newbie
Posts: 4
Joined: Mon Aug 11, 2008 11:14 am

Email submission with maths

Post by apg1985 »

Hi,

Ive got a form with 2 select boxes, inputbox and a submit button. The first select box is a list of figures, when the user selects a figure they go to the next select box which has yes and no. If they select no nothing happens but if they select yes it takes 10% away from the figure and when the submit button is hit it sends the answer to my email.

Below is the code ive got so far but could be completely wrong and also the wrong way of doing it but should give you a idea of what im trying to do. If I could do the whole thing through the email page that would be alot better.

HTML PAGE:

Code: Select all

 
<?php
$price = (float) $_POST['select1'];
if ($_POST['select2'] == 'yes') {
    $price *= 0.9;
}
?>
<form action="1testformphp.php" method="post" name="form1" id="form1">
<table width="500px">
<tr>
<td>Select value</td>
<td>
<select name="select1">
<option name="1000" value="1000">1000</option>
<option name="2000" value="2000">2000</option>
</select>
<td>
</tr>
<tr>
<td>Select Yes or No</td>
<td>
<select name="select2">
<option name="selectbox">select box</option>
<option name="yes" value="yes" id="yes">yes</option>
<option name="no" value="no" id="yes">no</option>
</select>
<td>
</tr>
<tr>
<td><input type="text" name="price" id="price" value="<?php echo $price; ?>"></td>
<td><input type="submit" name="submit" value="Submit"/></td>
</tr>
</table>
 
EMAIL CODE:

Code: Select all

 
<?php
if(isset($_POST['submit'])) {
 
$to = ""; 
$subject = "FORM"; 
$price = $_POST['price']; 
  
$body = "$price"; 
  
header("Location: index.php"); 
mail($to, $subject, $body); 
} 
else 
{
echo ("Not Sent");
}
?>
 
Post Reply