File: fwphp/glomodul/z_examples/book_video/03steinmetz_2008/1_examples/fahrenheit2celsius_post.php

Recommend this page to a friend!
  Classes of Slavko Srakocic  >  B12 PHP FW  >  fwphp/glomodul/z_examples/book_video/03steinmetz_2008/1_examples/fahrenheit2celsius_post.php  >  Download  
File: fwphp/glomodul/z_examples/book_video/03steinmetz_2008/1_examples/fahrenheit2celsius_post.php
Role: Auxiliary script
Content type: text/plain
Description: Auxiliary script
Class: B12 PHP FW
Manage database records with a PDO CRUD interface
Author: By
Last change:
Date: 2 months ago
Size: 626 bytes
 

Contents

Class file image Download
<html>
<head><title>Temperature Conversion</title></head>
<body>
 
<?php if ($_SERVER['REQUEST_METHOD'] == 'GET') { ?>
 <form action="<?php echo $_SERVER['PHP_SELF'] ?>"
       method="POST">
   Fahrenheit temperature:
   <input type="text" name="fahrenheit" /><br />
   <input type="submit" value="Convert to Celsius!" />
 </form>
 
  <?php }
else if (
$_SERVER['REQUEST_METHOD'] == 'POST') {
 
$fahrenheit = $_POST['fahrenheit'];
 
$celsius = ($fahrenheit - 32) * 5 / 9;
 
 
printf("%.2fF is %.2fC", $fahrenheit, $celsius);
}
else {
 die(
"This script only works with GET and POST requests.");
}
?>
 
</body>
</html>

For more information send a message to info at phpclasses dot org.