self processing forms

From: Date: Mon, 10 Jun 2002 22:16:48 +0000
Subject: self processing forms
Groups: php.general 
Request: Send a blank email to php-general+get-101464@lists.php.net to get a copy of this message
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

« previous php.general (#101464) next »