Sunday, 23 October 2016

F-C-F Temperature Converter





<?php

echo "<bodystyle='background:url(https://67.media.tumblr.com/63374d7d328956719d92fd0ef8103b5c/tumblr_n8opg8pMkR1t19jpho1_500.gif);'>";


    function fahrenheit_to_celsius($given_value)
    {
        $celsius=5/9*($given_value-32);
        return $celsius ;
    }

    function celsius_to_fahrenheit($given_value)
    {
        $fahrenheit=$given_value*9/5+32;
        return $fahrenheit ;
$celsius = ($fahrenheit - 32) / 1.8;
    }

?>

<html><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

<link rel="stylesheet" type="text/css" href="tc.css">
    <head>
        <c><title>F-C-F Temp.Converter</c></title>
    </head>
    <body>
        <form action="" method="post">
        <table>
           
          <h1 align=center>Online Temperature Converter</h1>
         <hr>

  <td colspan="15"><img src="snow-cold-thermometer.jpg" width="400" height="500"/></td>
        
       
        
        <tr>
        
                <td>
                    <select name="first_temp_type_name">
                        <option value="fahrenheit">Fahrenheit (F)</option>
                        <option value="celsius">Celsius (C)</option>
                    </select>
                </td>
            </tr>
            <tr>
                <td>
                    <input type="text" name="given_value">
                </td>
            </tr>
            <tr>
                <td>
                    <select name="second_temp_type_name">
                        <option value="celcius">Celcius (C)</option>
                        <option value="fahrenheit">Fahrenheit (F)</option>
                    </select>
                </td>
            </tr>
            <tr>
                <td>
                    <input type="submit" name="btn" value="Convert">
                </td>
            </tr>
            <tr>
               <td>
                    <?php
                    if(isset($_POST['btn']))
                    {
                        $first_temp_type_name=$_POST['first_temp_type_name'];
                        $second_temp_type_name=$_POST['second_temp_type_name'];
                        $given_value=$_POST['given_value'];
                        if($first_temp_type_name=='fahrenheit')
                        {
                            $celsius=fahrenheit_to_celsius($given_value);
                            echo "$given_value F = $celsius C";
                        }
                        if($first_temp_type_name=='celsius')
                        {
                            $fahrenheit=celsius_to_fahrenheit($given_value);
                            echo "$given_value C= $fahrenheit F";
                        }
                        
                        
                    }
                    
                    ?>
                </td>
                
            </tr>
        </table>
        </form>
    </body>
</html>


*the CSS coding

c {
font: "Invasion2000", serif;
font-size: 22pt;
color: #FF0000;
font-family: "Invasion2000";
font-style: italic;

text-shadow: #000000;
}

No comments:

Post a Comment