Learning PHP and MySQL

Example 10-08 PHP feet-to-meters converter

<head>
<
title>Feet  to  meters  conversion</title>
</
head>
<
body>
<?
php
//  Check  to  see  if  the  form  has  been  submitted
$feet  =  $_GET["feet"];
if  (
$_GET[feet]  !=  NULL){
echo  "<strong>$feet</strong>  feet  converts  to  <strong>";
echo  
$feet  *  0.3048;
echo  
"</strong>  meters.<br  />";
}
?>
<form  action="<?php  echo($_SERVER['PHP_SELF']);  ?>"  method="GET">
<label>Feet:
<input  type="text"  name="feet"  value="<?php  echo  $feet;  ?>"  />
</label>
<input  type="submit"  value="Convert!"  />
</form>
</body>
</html>

Posted by on 08/18 at 11:38 AM

Next entry: Example 10-09 Converting between time zones based on user input

Previous entry: Example 10-07 Checking input from a checkbox or a multiple select

<< Back to main