I have a small idea I and would like to know if someone could help with it
I have proxy sites and would like to be able to save the inputted url into a text file so I am able to later know the most popular sites and make sure the proxy is up to par for those sites.
This is the current form field that I would like to save the inputted url and in the text file all the urls on individual lines. Would be great if the saved url were live links so I could just click on them.
I tried to use this but it does not save all queries on some and I dont know what to chmod the txt file to
PHP Code:
<!-- save query //--> <?php
if($_POST['q']){ $file_name = "something.txt";
$file_open = fopen("something.txt","a+"); fwrite($file_open, $_POST['q']); fclose($file_open); } ?> <!-- end save query //-->
The undefined index is your $_POST['q'] which needs to be tested before using it.
Try something like this:
PHP Code:
<?php if(isset($_POST['q'])){ $postdata = $_POST['q']; $fp = "something.txt"; if(!is_file($fp)) { echo $fp." didn't exist, trying to touch and chmod<br/>"; touch($fp); @chmod($fp, 0666); } if(!is_writable($fp)) { echo $fp." is not writable<br/>"; $error = true; } else { echo "...". $fp." is OK <br/>"; } if(!$error) { $data = file_get_contents($fp); // echo $data; //uncomment this ln to see the data prior to writing $data .= "\r\n".$postdata; // echo $data; // uncomment this ln to see the data after writing file_put_contents($fp, $data); echo "... And we're done!"; } } ?>
The scripts definately doing something right, but there seems to be some probs with it, wouldn't know without the whole source though
Keep at it - you're going to the right direction at least, 'cause It's logging some urls :>