I am using the O'Reilly "Programming PHP" manual, and have copied the code
from Example 7.3, p. 166. I have the magic_quotes_gpc set to ON in php.ini
(though toggling between on and off doesn't seem to have any effect). My
processed form reports "0.00F is -17.78C " regardless of the initial
fahrenheit temperature I enter. Moreover, using another version of this
script, as shown in Example 7.4, p. 167, simply clears the text field, and
never returns an output. I can't figure out why I am not getting a correct
output - perhaps something in my php.ini file? A copy of the code I am using
(Example 7.3) is as follows:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<html>
<head>
<title>Untitled</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' />

<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);
//echo "The temperature in degrees celsius is $celsius";
} else {
die("This script only works with GET and POST requests.");
}
?>

</body>
</html>

**************************************************

Thanks much in advance, Bill





-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to