NameSilo

Html and javascript help...

Spaceship Spaceship
Watch

Untitled

ThE POwEr oF An IDeAEstablished Member
Impact
28
Hey guys!!

I want to create a webpage so that it can be accessed if and only if it is accessed through a particular site.

For eg. if i give you a url here:

www.example.com/test.html

The actual contents of text should be displayed only if i click on the above link!! ( Only through namepros that is... )...... It should show an error message otherwise...

can someone tell me how you do it in javascript or php....??

Thanks

Untitled
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
AfternicAfternic
in php you can use the $_SERVER['HTTP_REFFERER'] variable, but beware, as it can be easily be spoofed.
 
0
•••
Is there a safer and secure way to do it???
 
0
•••
Answer: no.

Correct code is:
PHP:
$_SERVER['HTTP_REFERER']

You can never rely on the referring information, as this article explains.

Joe
 
0
•••
Untitled said:
Is there a safer and secure way to do it???

Why don't you just use a login system or simply password protect the directory? I know this isn't exactly what you're asking, but it's a safe alternative to referring information. Since the former can be slightly more complex, here's some basic info on protecting a directory: http://www.htmlite.com/HTA006.php

I've tried this myself and it does work. Good luck.
 
0
•••
If you own the other website, im pretty sure it's possible to make it more secure:

On the first site (with the link to the other site):
PHP:
<form method="POST" action="http://www.yourdomain.com">
<input type="hidden" name="referral" value="2897hj29m03y87" />
<input type="image" src="/imagesource/blah.gif" />
</form>

And on the second site:
PHP:
<? if (!isset($_POST['referral'])){
echo "Access Denied";
exit;
} 
else if ($_POST['referral'] == "2897hj29m03y87"){
echo "Access Granted";
}

I'm not sure if that would work 100%, although I believe the concept is there. Anyone care to develop?
 
0
•••
By no means is this secure, but it is what you asked for.
http://www.zero-cms.com/Test/referrer/

PHP:
<?
$site = md5("http://www.zero-cms.com/Test/referrer/firstsite.php");
?>
<form method="POST" action="http://www.zero-cms.com/Test/referrer/secondsite.php">
<input type="hidden" name="val" value="<? echo $site; ?>" />
<input type="submit" value="Go to second site"/>
</form>

PHP:
<?
if (md5($_SERVER['HTTP_REFERER']) !== $_POST['val']){
echo "Access Denied";
exit;
}
else if (md5($_SERVER['HTTP_REFERER']) == $_POST['val']){
echo "Access Granted!";
}
?>
 
Last edited:
0
•••
0
•••
Dynadot — .com TransferDynadot — .com Transfer

We're social

Domain Recover
NameMaxi - Your Domain Has Buyers
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back