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? Quote Link to comment 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"; } ?> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.