i have .txt file and i want to add some string on that file.The string i'm getting from my page by a <textarea> form. I used fwrite() function. The problem is it does n't showing any problem but it also does not writing on that txt file. So could u please help me. I got the code from another site.
the code is -
====
$filelocation = "mytext.txt";
if (!file_exists($filelocation)) {
echo "Couldn“t find datafile, please contact administrator!";
}
else {
$newfile = fopen($filelocation,"r");
$content = fread($newfile, filesize($filelocation));
fclose($newfile);
}
$content = stripslashes($content);
$content = htmlentities($content);
$pass="password";
if (!$pw || $pw != $pass){
$content = nl2br($content);
echo $content;
}
else {
if ($newcontent){
$newcontent = stripslashes($newcontent);
$newfile = fopen($filelocation,"w");
fwrite($newfile, $newcontent);
fclose($newfile);
echo "Text was edited.<form><input type=\"submit\" value=\"see changes\"></form>";
}
else{
echo "<form>
<textarea name=\"newcontent\" cols=50 rows=15 wrap=\"virtual\">";
echo $content;
echo "</textarea>
<input type=\"hidden\" name=\"pw\" value=\"$pass\"><br><input type=\"submit\" value=\"edit\">
</form>";
}
}
====
its working without an error but it doesnot writing on that file..so what will be the problem ??help!!!!!