This is a really beginner question. I'm trying to learn php. To do so, I started reading w3 schools php lessons and some other basic stuff. Right now, I'm using Mac Os Lion.
According to this tutorial - http://www.procata.com/blog/archives/2007/10/28/working-with-php-5-in-mac-os-x-105/ - php is working here. Unfortunately, I'm having some troubles trying to execute the following code:
- Code: Select all
<html>
<body>
<?php
$name = $_POST['name'];
$email = $_POST['email'];
$fp = fopen("formdata.txt", "w");
$savestring = $name . "," . $email . "n";
fwrite($fp, $savestring);
fclose($fp);
echo "<h1>You data has been saved in a text file!</h1>";
?>
</body>
</html>
When I say "execute the following code", I mean "open the .php file on Firefox, making sure the file is located at localhost".
This is what appeared on my screen:
Warning: fopen(formdata.txt) [function.fopen]: failed to open stream: Permission denied in /Library/WebServer/Documents/save.php on line 7
Warning: fwrite() expects parameter 1 to be resource, boolean given in /Library/WebServer/Documents/save.php on line 9
Warning: fclose() expects parameter 1 to be resource, boolean given in /Library/WebServer/Documents/save.php on line 10
I've googled it, but didn't find any solutions. I appreciate if you could help me here.


