Simple PHP Question

steve1717

macrumors newbie
Original poster
Jul 18, 2007
20
0
I've turned one of my Macs into a web server and have successfully got Apache and PHP running. What I can't seem to figure out is how to use PHP to take the contents of a simple HTML form and save them to a text file. Could anyone kindly point me in the right direction? I've read many example scripts of how to do this but none seem to pertain directly to a Mac web server.:confused:
 

zimv20

macrumors 601
Jul 18, 2002
4,388
7
toronto
I've read many example scripts of how to do this but none seem to pertain directly to a Mac web server.
what do you mean by "mac web server"? osx comes w/ apache, which works very well with php. so what is it about your example scripts that doesn't apply?
 

steve1717

macrumors newbie
Original poster
Jul 18, 2007
20
0
Simple PHP Question

I have both Apache and PHP on. Trouble is, I can't get the PHP script to save very simple output in the Library/WebServer/Documents folder where the scripts are stored (I have already given the folder 777 read-write permissions). These are the 2 scripts -- in the case below, I get a file called "file.txt" but it has nothing in it. Any idea what I am doing wrong?

HTML:

<form action="save.php" method="POST">
<textarea name="content"></textarea>
<br>
<input type="submit" value="Save">
</form>

PHP:

<?
$content = $_POST['content'];
$file = "file.txt";
$Saved_File = fopen($file, 'w');
fwrite($file, $content);
fclose($file);
?>