CloudConX Posted October 29, 2007 Share Posted October 29, 2007 <?php $filename = 'logfile.txt'; if (is_writable($filename)) { if (!$handle = fopen($filename, 'a')) { echo "Cannot open file ($filename)"; exit; } if (fwrite($handle, $input) === FALSE) { echo "Cannot write to file ($filename)"; exit; } echo "Success, wrote ($input) to file ($filename)"; fclose($handle); } else { echo "The file $filename is not writable"; } ?> in the url I have http://www.site.com/logger.php?input='blahblah' I get an output of "Success, wrote () to file (logfile.txt)";" no matter what the variable I use (eg. logger.php?blah=blah) returns the same thing This will not write the input to the text file... permissions set. Any guesses? Link to comment https://forums.phpfreaks.com/topic/75288-simple-write-to-file-script/ Share on other sites More sharing options...
bwochinski Posted October 30, 2007 Share Posted October 30, 2007 Looks like you either need register globals to be "on" (not recommended) or to use the $_GET[] variables: <?php $filename = 'logfile.txt'; if (is_writable($filename)) { if (!$handle = fopen($filename, 'a')) { echo "Cannot open file ($filename)"; exit; } if (fwrite($handle, $_GET['input']) === FALSE) { echo "Cannot write to file ($filename)"; exit; } echo "Success, wrote ($_GET['input']) to file ($filename)"; fclose($handle); } else { echo "The file $filename is not writable"; } ?> Link to comment https://forums.phpfreaks.com/topic/75288-simple-write-to-file-script/#findComment-380786 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.