/    Sign up×
Community /Pin to ProfileBookmark

php loading a page clicking banner

An user clicks on my banner that open my php page
I want this page is loaded only clicking on the banner and not putting the ‘web address directly in the browser
It’s possible?

to post a comment
PHP

12 Comments(s)

Copy linkTweet thisAlerts:
@PETTEJul 14.2010 — If I understand what you're trying to say. Yes it is possible. You'll need to look into a language called Ajax. If you don't mind reloading the page just include the page in the current page which has the banner and exit after checking that the banner was clicked.
Copy linkTweet thisAlerts:
@Jarrod1937Jul 14.2010 — An easier route is just to lookup the referrer. It can be easily spoofed for those who want to, so it depends on how fool proof you want it.
Copy linkTweet thisAlerts:
@grigioneauthorJul 15.2010 — ok thank you can you post some example of code how to make ?

thanks
Copy linkTweet thisAlerts:
@grigioneauthorJul 15.2010 — ok.. but this work if the banner is located in my page that i specify in script but i want the system working for banner located in any webpage on internet
Copy linkTweet thisAlerts:
@Jarrod1937Jul 15.2010 — The banner is on their site correct? Thus when someone clicks on the banner from their site, it will have a referrer url of their site. If someone goes directly to the url, no referrer is sent.
Copy linkTweet thisAlerts:
@grigioneauthorJul 15.2010 — correct but i'm new in php can you help me with code ?
Copy linkTweet thisAlerts:
@grigioneauthorJul 15.2010 — [code=php]<?php
if($_SERVER['HTTP_REFERER'] == NULL) {
echo "access denied";
exit();
} else {
// Insert your page contents here.

header("Location: http://site.com");
}
?> [/code]


i'm trying this if i type url in browser it give me access denied but if click banner

it give me error coookie and don't go to page

where is error?
Copy linkTweet thisAlerts:
@Jarrod1937Jul 15.2010 — What do you mean by "it give me error coookie"? Does it give you a specific error? If so, what is that error? As far as i can see, nothing in the code sample you gave should be giving a cookie error.
Copy linkTweet thisAlerts:
@grigioneauthorJul 16.2010 — ok working it was a my mistake...

ok but it can be easily spoofed

A best alternative to $_SERVER['HTTP_REFERER'] what is ?
Copy linkTweet thisAlerts:
@Jarrod1937Jul 16.2010 — The real question is how secure do you want it? Almost any method can be spoofed, its just a matter of how easily. Is this merely for an ad site? Or do you plan on using this for some truly secure information (in which case its a very bad approach)?
Copy linkTweet thisAlerts:
@grigioneauthorJul 16.2010 — not only for ad site but i want a minimal protection...

i have tried also the define method: Suppose that i want protect page index.php containing a form

i have inserted function define in link.php that is page linked by banner :
[code=php]<?php
define('_VALID_INCLUDE', TRUE);
include('index.php');

/* rest of file */

?>[/code]


and in index.php i have inserted:
[code=php]defined('_VALID_INCLUDE') or die('Direct access not allowed.');
[/code]

in this mode working but in browser url of link.php is visible and it's available for direct access to form?
×

Success!

Help @grigione spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.23,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...