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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.