When I use a php form to update my flat file db from this local machine, it works with no problems.
However when associates on the same network (but different machines) try to use the form they get this error -
This is the form -Warning: fopen(news.txt) [function.fopen]: failed to open stream: Permission denied in C:\Source\dir\org\dir\action.php on line 16
Sorry couldn't open file
Warning: fclose(): supplied argument is not a valid stream resource in C:\Source\dir\org\dir\action.php on line 63
Code: Select all
<?php
$fp = fopen('news.txt','a');
if ($fp=="") {
echo "Sorry couldn't open file<br>";
} else {
if ($_POST['images']=="") {
echo "<div class=\"button1\">please <a class=\"button1\" href=\"javascript:history.go(-1)\">
<b>go back</b></a>and add image link.<BR><i>the animals are important</i>.</div>\n\n";
} else {
if ($_POST['news']=="") {
echo "<div class=\"button1\">please <a class=\"button1\" href=\"javascript:history.go(-1)\">
<b>go back</b></a>and add some details.<BR><i>the details are important</i>.</div>\n\n";
} else {
if(strstr($_POST["news"],"&")) {
echo "<div class=\"button1\">the text cannot contain the ampersand symbol - &<a class=\"button1\" href=\"javascript:history.go(-1)\">
<b>please go back</b></a>and correct.<BR><i>these things are important</i>.</div>\n\n";
} else {
if(!strstr($_POST["images"],"[img]")) {
echo "<div class=\"button1\">the images link must be formatted correctly<br>ie - contain '<b></b>
<br><a class=\"button1\" href=\"javascript:history.go(-1)\">
<b>please go back</b></a></div>\n\n'";
} else {
if (!preg_match("/^([a-zA-Z0-9])+([\.a-zA-Z0-9_-])*@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-]+)*\.([a-zA-Z]{2,6})$/", $_POST['email'])) {
echo "<div class=\"button1\">invalid e-mail address<br><a class=\"button1\" href=\"javascript:history.go(-1)\">
<b>please go back</b></a></div>\n\n";
}else {
$line = date("d.m.y") . "¬" . $_POST['name'] . "¬".$_POST["email"] . "¬".trim($_POST["subject"]). "¬".$_POST["url"]. "¬".$_POST["images"];
$line .= "¬" . $_POST['news'];
$line = str_replace("\r\n","<BR></BR>",$line);
$line = str_replace(" < "," LESS THAN ",$line);
$line = str_replace(" > "," GREATER THAN ",$line);
$line = str_replace(" >= "," GREATER THAN OR EQUAL TO ",$line);
$line = str_replace(" <= "," LESS THAN OR EQUAL TO ",$line);
$line = str_replace(" & "," and ",$line);
$line = str_replace("&","and",$line);
$line = stripslashes($line);
$line .= "\r\n";
fwrite($fp, $line);
echo "all sorted...cool<br>
<a href=\"javascript:self.close()\"><small>close window</small></a>";
}
}
}
}
}
}
if(!fclose($fp)) {
}
?>The file 'news.txt' is in the same directory as the php file containing the above code.