htmlblock.co.uk Posted November 24, 2006 Share Posted November 24, 2006 Im still working on my new website SiteRanker.org and I require some help please.I have a PHP script where every url entered gets logged in a txt file.But say someone enters google.co.uk 3 times, it will go on my log 3 times.I want to adapt the code so that it check to see if it is already there, so did does not put it in the text file more than once.Below is the PHP code which adds it to the txt file. The form which sends the url send $siteurl (there url) to the script below to be insereted in to the txt file.Please help me resolve this problem. If you fix this I am more than happy to give you a free copy of HTMLBlock from htmlblock.co.uk is i own this to.[sub]<?phpif ($siteurl == "") {echo "Incorrect url. Please visit www.siteranker.org";exit;}else$textfile = ("links.txt");$filename = 'links.txt';$fp = fopen($textfile, "a+");if (file_exists($siteurl)) { echo "";} else {fputs ($fp, "<p><a href=http://siteranker.org/validate.php?siteurl=$siteurl target=\"_blank\">$siteurl</a></p>\n");fclose($fp);}?>[/sub]thank you again I hope i get this working soon. If you require any more information to fix this please post a message and I shall reply back. Link to comment https://forums.phpfreaks.com/topic/28329-please-help-with-exists-php-script/ Share on other sites More sharing options...
CheesierAngel Posted November 24, 2006 Share Posted November 24, 2006 For avoiding the user is refreching his browser and the url gets inserted mulitple times you can hold a logwith the previous entered url. If the entered url is the same as the previous entered url, than there is no needto update the text file. I would make the log like IP:URL but thats only how you prefer it to be done ... Link to comment https://forums.phpfreaks.com/topic/28329-please-help-with-exists-php-script/#findComment-129569 Share on other sites More sharing options...
htmlblock.co.uk Posted November 24, 2006 Author Share Posted November 24, 2006 sorry my website does not work on being refreshed as it posts $siteurl. When on the page if you refresh it will not add it again, only when it is posted to the result page with the variable $siteurl that why i need the code to check to see if the $siteurl is already in the list. Link to comment https://forums.phpfreaks.com/topic/28329-please-help-with-exists-php-script/#findComment-129575 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.