On the last page I showed you how to make an interface for someone else's script. Now it is time for you to make your own tool. For this example, we will make a form to convert kilometers to miles.
The form can be basic HTML, a text input, a submit button a text input for the results and a table to hold it all together.
Notice that the first text input is named "km" so it will become $km when submitted to a PHP script. You don't want your script executing if nothing has been submited so you can test with isset() to see if $km has been set. A quick check with Google and you find that one mile is 1.609344006 km's and a little arithmetic gives you the PHP to convert miles to kilometers:
$mi = $km/1.609344006; ?>
To generate an ouput, simply echo it in the "miles" text box
|
|
|