Welcome to WebmasterWorld Guest from

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

reciprocal link checker

a sample code or hints please

10:43 pm on Nov 2, 2004 (gmt 0)

New User

10+ Year Member

joined:Apr 18, 2004
votes: 0

Hello Everyone,

I am coding the reciprocal link exchange form which there is function to check if my site info and link already been add on the partner site page or not.

Please anyone who works on similar function gives me a hint how it works or any sample code would be a great appreciation.

Thanks in advance.


10:03 am on Nov 3, 2004 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Mar 19, 2003
votes: 0

try using
to load up the page that the user designates as the one where they've added your url, and then
(more difficult, but able to find links if they've done weird stuff like <a class="links" href="ht*p://yoursite.com">, or if they've used single quotes - though this doesn't happen so much - you could always put a note on an error page explaining this).

$myurl = 'ht*p://www.mysite.com';
$checkhtml = file_get_contents($submittedurl);
if(preg_match('#<a[^>]*href[\s]*=[\s]*['"]?'.$myurl.'#', $checkhtml)) {
echo 'thanks for the link!';
/* do your processing stuff */
} else {
echo 'freeloader #(}@!';
/* do your error stuff */

the line with 'preg_match' might not work - I have to correct my regexes all the time - if not, a simple
will work, though more limited, but if you don't understand regexes, it has the extra benefit of being easily understandable. So if this doesn't work, replace the preg_match line with this:
if(strpos($myurl, $checkhtml)!== false) {

Note that this won't find javascript links, or redirect links, common in directories. This could also go on your error page - that the link needs to be an ordinary HTML link.

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members