1. Home
  2. Computing & Technology
  3. PHP / MySQL

Convert Temperature

By , About.com Guide

1 of 4

Setting Up the Form

The first step in creating an online temperature conversion program, is to collect the data from the user. In our case this forms collects the degrees and the units the degrees are measured in. We are using a drop down menu for the units and giving them four options. This form uses the $_SERVER[’PHP_SELF’] command to indicate it sends the data back to itself.

Put the code below into a file called convert.php

<head>
<title>Convert Temperature</title>
</head>
<body>
<h2>Temperature Conversion</h2>
<form action = "<?php echo $_SERVER[’PHP_SELF’]; ?>"
method = "GET">
Degrees:
<input type = "text" name = "degree" size=4>
<select name="scale"> <option value="celcius">Celsius</option> <option value="fahrenheit">Fahrenheit</option> <option value="kelvin">Kelvin</option> <option value="rankine">Rankine</option> </select>
<br/>
<input type = "submit" name = "Convert Temperature"/>
</form>

Explore PHP / MySQL
About.com Special Features

Holiday Central

What to eat, where to go, fun things to do and how to save money on the perfect gifts. More >

Family Tech Center

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

  1. Home
  2. Computing & Technology
  3. PHP / MySQL
  4. Step By Steps
  5. PHP Calculator - Convert Temperature - PHP Convert Temperature

©2009 About.com, a part of The New York Times Company.

All rights reserved.