Temperature converter
change the Temperature from Celsius to Fahrenheit and from Fahrenheit to Celsius
Create a temperature.php file and add following code to it
<!Doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Temperature </title>
</head>
<body bgcolor="lightgray">
<?php error_reporting(E_ALL^E_NOTICE)?>
<div align='Center'>
<h1>Temperature</h1>
<form name="form1" action="temperature.php" method="POST" >
<table >
<tr><td>Enter Temperature</td><td><input type="text" name="value1" /></td></tr>
<tr><td>Celsius to Fahrenheit </td><td><input type="radio" name="temp" value="celTofar" />
</td>
</tr>
<tr><td>Fahrenheit to Celsius </td><td><input type="radio" name="temp" value="farTocel" /> </td>
</tr>
<tr><td colspan="2" align="Center"><input type="Submit" name="submit1" value="Calculate" /></td></tr>
<tr><font color="red"><td>Changed Value is :</td><td><?php
//echo $Value1." Total " .$Value2;
if(isset($_POST['submit1'])){
$Value1=$_POST['value1'];
$Source=$_POST['temp'];
if($Source=="farTocel"){
echo $Value1 * 9/5 +32 ."`C";
}else{
echo ($Value1-32) * 5/9 ."`F";
}
//echo $Value1." Total " .$Value2 .$operation;
}
?></td></font></tr>
</table
</form>
</div>
</body>
</html>
No comments:
Post a Comment