Hello everyone,
I'm very new to PHP and I'm keen to learn how it all works. I've been looking for help all day and reading tutorials etc which is how I came accross this forum - so here's hoping for some answers :)
First off I'll tell you what I'm doing. I'm making a calculator of some form which will do some simple calculations on the numbers entered into a form. For example, adding, multiplying etc. At the moment just to get me going I want to add two numbers together which would have been entered by the user. The calculator itself will be used to estimate the top speed of a car depending on what's been entered (doesn't have to be accurate of course, it's by no means professional or anything like that it's just college work).
I may have made some silly mistakes because of how new all this is to me, but here is my code:
[code=html]
<html>
<head>
<title>Form :: Results</title>
</head>
<body>
<h1>Top Speed Calulator</h1>
<img src="gtx.jpg" alt="My VW Scirocco GTX">
<br>
<br>
Here are the options you submitted:
<br>
<br>
<table border="3" bgcolor=#FFFF99 >
<tr>
<th>Property</th>
<th>Value</th>
</tr>
<tr>
<td>Chassis Weight (lbs)</td>
<td><?php echo number_format($ _POST['chassis']); ?></td>
</tr>
<tr>
<td>Brake Horse Power (BHP)</td>
<td><?php echo number_format($ _POST['bhp']); ?></td>
</tr>
<tr>
<td>Number of Doors (3\5)</td>
<td><?php echo htmlspecialchar s($_POST['doors']); ?></td>
</tr>
<tr>
<td>Dropped Suspension? Lowered by... (mm)</td>
<td><?php echo htmlspecialchar s($_POST['drop']); ?></td>
</tr>
<tr>
<td>Engine Modifications</td>
<td><?php echo htmlspecialchar s($_POST['mods']); ?></td>
</tr>
<tr>
<td>Fuel Feed Type</td>
<td><?php echo htmlspecialchar s($_POST['fuelfeed']); ?></td>
</tr>
<tr>
<td>Your email address (for our newsletter)</td>
<td><?php echo htmlspecialchar s($_POST['email']); ?></td>
</tr>
</table>
<?php $speed = $chassis + $bhp;?>
<?php echo number_format($ speed); ?>
<br>
</body>
</html>
[/code]
As you can probably see, right now it only shows you what the user has entered on the form on the previous page, but the code at the bottom is where I'm trying to get the calculations to work - right now adding the chassis weight and the bhp values together.
Can anyone shed some light on this for me?
Many thanks
PS - I can give you the code for the form itself if that's of any help to anyone
I'm very new to PHP and I'm keen to learn how it all works. I've been looking for help all day and reading tutorials etc which is how I came accross this forum - so here's hoping for some answers :)
First off I'll tell you what I'm doing. I'm making a calculator of some form which will do some simple calculations on the numbers entered into a form. For example, adding, multiplying etc. At the moment just to get me going I want to add two numbers together which would have been entered by the user. The calculator itself will be used to estimate the top speed of a car depending on what's been entered (doesn't have to be accurate of course, it's by no means professional or anything like that it's just college work).
I may have made some silly mistakes because of how new all this is to me, but here is my code:
[code=html]
<html>
<head>
<title>Form :: Results</title>
</head>
<body>
<h1>Top Speed Calulator</h1>
<img src="gtx.jpg" alt="My VW Scirocco GTX">
<br>
<br>
Here are the options you submitted:
<br>
<br>
<table border="3" bgcolor=#FFFF99 >
<tr>
<th>Property</th>
<th>Value</th>
</tr>
<tr>
<td>Chassis Weight (lbs)</td>
<td><?php echo number_format($ _POST['chassis']); ?></td>
</tr>
<tr>
<td>Brake Horse Power (BHP)</td>
<td><?php echo number_format($ _POST['bhp']); ?></td>
</tr>
<tr>
<td>Number of Doors (3\5)</td>
<td><?php echo htmlspecialchar s($_POST['doors']); ?></td>
</tr>
<tr>
<td>Dropped Suspension? Lowered by... (mm)</td>
<td><?php echo htmlspecialchar s($_POST['drop']); ?></td>
</tr>
<tr>
<td>Engine Modifications</td>
<td><?php echo htmlspecialchar s($_POST['mods']); ?></td>
</tr>
<tr>
<td>Fuel Feed Type</td>
<td><?php echo htmlspecialchar s($_POST['fuelfeed']); ?></td>
</tr>
<tr>
<td>Your email address (for our newsletter)</td>
<td><?php echo htmlspecialchar s($_POST['email']); ?></td>
</tr>
</table>
<?php $speed = $chassis + $bhp;?>
<?php echo number_format($ speed); ?>
<br>
</body>
</html>
[/code]
As you can probably see, right now it only shows you what the user has entered on the form on the previous page, but the code at the bottom is where I'm trying to get the calculations to work - right now adding the chassis weight and the bhp values together.
Can anyone shed some light on this for me?
Many thanks
PS - I can give you the code for the form itself if that's of any help to anyone
Comment