boontoony Posted February 11, 2009 Share Posted February 11, 2009 Hi, I was wondering if i could get some help on this form. I am basically calculating an amount of metres by the price per metre. I have the form set up, below, but need help actually processing the calculation. How do i echo the following on "calculate_price.php". example 20 metres (which was selected from the drop down menu) = $the price of metres Any help would be appreciated. <form method="post" action="calculate_price.php"> <td align="left" valign="top" class="content"><table border="0"> <tr> <td nowrap>Metres</td> <td><select name="metres" style="width:100px; "> <option value="15">15</option> <option value="20">20</option> <option value="25">25</option> <option value="30">30</option> <option value="35">35</option> <option value="40">40</option> <option value="45">45</option> <option value="50">50</option> <option value="55">55</option> <option value="60">60</option> <option value="65">65</option> <option value="70">70</option> <option value="75">75</option> <option value="80">80</option> </select></td> </tr> </table> <input name="type" type="radio" value="24"> ex 1 - $24 per metre<br> <input name="type" type="radio" value="27"> ex 2 - $27 per metre<br> <input name="type" type="radio" value="28"> ex 3 - $28 per metre<br> <input name="type" type="radio" value="30"> ex 3 – $30 per metre<br> <input type="submit" name="Submit" value="Calculate"> </form> Link to comment https://forums.phpfreaks.com/topic/144716-calculate-price/ Share on other sites More sharing options...
5kyy8lu3 Posted February 11, 2009 Share Posted February 11, 2009 is this what you're looking for? <?php $price = $_POST['metres'] * $_POST['type']; echo 'The price for ' . $_POST['metres'] . ' metres at $' . $_POST['type'] . ' per metre comes to a total of $' . $price . '.'; ?> this should calculate your price, just make sure you validate your form data for security reasons Link to comment https://forums.phpfreaks.com/topic/144716-calculate-price/#findComment-759381 Share on other sites More sharing options...
boontoony Posted February 11, 2009 Author Share Posted February 11, 2009 Thank you very much. That is exactly what i was after. I am very much a beginner, so I wouldn't have a clue about validating anything. :-\ Link to comment https://forums.phpfreaks.com/topic/144716-calculate-price/#findComment-759384 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.