Jump to content

Please help with exists PHP Script


htmlblock.co.uk

Recommended Posts

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]<?php
if ($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

For avoiding the user is refreching his browser and the url gets inserted mulitple times you can hold a log
with the previous entered url. If the entered url is the same as the previous entered url, than there is no need
to update the text file. I would make the log like IP:URL but thats only how you prefer it to be done ...
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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.