I’m trying to write a self-processing form. I bought O’Reilly’s book “Programming PHP” and there’s a section on self-processing forms. I installed MAMP. I copied an example form from the book but it won’t run. I put them in the directory /Applications/MAMP/cgi-bin. It returns this error message:
No webpage was found for the web address: file:///Applications/MAMP/cgi-bin/%3C?php%20echo%20$_SERVER[‘PHP_SELF’]%20?%3E
Error code: ERR_FILE_NOT_FOUND
–
I tried putting the files into my Public directory, and on the desktop, and got the same error message. This is on a Macintosh.
I think the problem is in the “form action” line, but I don’t know how to fix it.
Here’s the code:
[code]
Temperature Conversion <?php $fahrenheit = $_GET['fahrenheit']; if (is_null($fahrenheit)) { ?><form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="GET">
Fahrenheit temperature:
<input type="text" name="fahrenheit" /><br />
<input type="submit" value="Convert to Celsius!" />
</form>
<?php }
else {
$celsius = ($fahrenheit - 32) * 5 / 9;
printf("%.2fF is %.2fC", $fahrenheit, $celsius);
} ?>
[/code]