Can any one please tell whats going on in this program? My one main doubt is about the 1st condition from where will we get the method for REQUEST_METHOD i mean the program is gng in the 1st if loop so REQUEST_METHOD == GET but where are we setting it.
<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" name="Convert to Celsius!" />
</form>
<?php
}
elseif ($_SERVER['REQUEST_METHOD'] == 'POST')
{
$fahr = $_POST['fahrenheit'];
$celsius = ($fahr - 32) * 5/9;
printf("%.2fF is %.2fC", $fahr, $celsius);
}
else
{
die("This script only works with GET and POST requests.");
}
?>
</body>
</html>
Once again I just say Thanks