开发者

Writing Details into a File

I am trying to write into a file work/log_file.txt upon submitting a page work/login.php. But the contents (form values from login.php) are not getting written. This is the code I used

   if(isset($_POST['submitform'])){
   $file="log_file.txt";
    $open = fopen($file, "a+"); //open the file,

  fwrite($open, "Name: " .$_POST['user'] . "\n"); //print / write the name.
   fwrite($open, "Colour: ". $_POST['color'] . "\n"); //print / write the colour.
   fclose($open); //close the opened file 

  }

I am running the code in a test server. I just saved file as log_file.txt in local and then uploaded it to test server folder work ,and run the code. But not get开发者_如何学Pythonting written to the file


Does the web server process have write permissions for the file?

Tip that will serve you well: turn on all errors while debugging:

ini_set('display_errors',1);
error_reporting(E_ALL);

Any number of things could be off, but you'll never know unless you see the notices and warnings.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜