Problem with writing form contents to file
Posted: Sat Nov 07, 2009 3:18 pm
Hello,
I am writing two php scripts one for form and other one to write the values of a form using php into a file and also print the values on the another html page. I dont know why it is not writing into the file but if I print the form values in the script, that is getting printed on the html page. The fopen should create the file but until I set the permissions manually it shows the error, " permission denied" on the html page. I even checked the path of the file. When I Execute the file, it directly goes to the else clause, "Cannot write to the file". Could anyone please help me with this. I am using this code for writing to the file:
Thanks
Ramya
I am writing two php scripts one for form and other one to write the values of a form using php into a file and also print the values on the another html page. I dont know why it is not writing into the file but if I print the form values in the script, that is getting printed on the html page. The fopen should create the file but until I set the permissions manually it shows the error, " permission denied" on the html page. I even checked the path of the file. When I Execute the file, it directly goes to the else clause, "Cannot write to the file". Could anyone please help me with this. I am using this code for writing to the file:
Code: Select all
$filename="test.txt";
if(is_writable($filename)){
if(!$fp = fopen($filename,'a')){
echo "cannot open file($filename)";
exit;
}
if($fp!=null)
{
fwrite($fp,$name);
fwrite($fp,$date);
fwrite($fp,$platform);
fwrite($fp,$browser);
fwrite($fp,$comments);
}
fclose($fp);
}
else
{
echo "Cannot write to the file";
}
Ramya