I am trying to have a page read and write to a txt file. I can't get it to do either. This is the php I have for reading:
<?php
function ReadFromFile() {
$FileName = "data/quotes.txt";
$Open = fopen($FileName, "r");
if ($Open) {
print ("Quotes:<p>\n");
$Data = file($FileName);
for ($n = 0; $n < count($Data); $n++) {
$GetLine = explode("\t", $Data[$n]);
print ("$getLine[0]<BR>\n$GetLine[1]<p>\n");
}
fclose($Open);
print ("<HR><P>\n");
} else {
print ("Unable to read from quotes.txt!<BR>\n");
}
} // End of ReadFromFile Function
?>
Then I have a form which should write to the file. This is the php in my form handler:
<?
function WriteToFile($Name, $Email, $Quote, $Quoter, $Book) {
$FileName = "data/quotes.txt";
$Open = fopen($FileName, "a");
if ($Open) {
fwrite($Open, "$Quote\t$Quoter\t$Book\t$Name\t$Email\n");
fclose($Open);
$Worked = TRUE;
} else {
$Worked = FALSE;
}
return $Worked;
} // End of WriteToFile Function
?>
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
<meta name="generator" content="Adobe GoLive 5">
<title>FormHandler</title>
</head>
<body bgcolor="#ffffff">
<p>
<?php
global $Array;
$CallFunction = WriteToFile($Array["Name"], $Array["Email"], $Array["Quote"], $Array["Quoter"], $Array["Book"]);
if ($CallFunction) {
print ("Your quote has been recieved.<BR>\n");
print ("<a href='quotes.php'>Return</a> to quotes.<BR>\n");
} else {
print ("Your submission was not processed due to a system error.<br> Please email webmaster.<br>\n");
}
?></p>
</body>
</html>
I have go the form information is being processed (It says "Your quote has been recieved") but it's not reading or writing. All permissions are set correctly.
-Searlyn