Jump to content

Storig form values to file


ramyakumar

Recommended Posts

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 quickly. I am using this code for writing to the file:

 

$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";
   }

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/180705-storig-form-values-to-file/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.