1. Computing & Technology

Discuss in my forum

Convert Temperature

By , About.com Guide

1 of 4

Setting Up the Form
Convert Temperature
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> 

©2012 About.com. All rights reserved.

A part of The New York Times Company.