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

Convert Temperature

By Angela Bradley, About.com

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

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

Easy ways to connect two computers for networking purposes. 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.