Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Help With $_SERVER['HTTP_REFERER']
Old 04-10-2010, 08:44 AM Help With $_SERVER['HTTP_REFERER']
ZoC
Skilled Talker

Posts: 68
Trades: 0
hello there,
can someone tell me how i can make this command

<?php
$website_referer = $_SERVER['HTTP_REFERER'];
if ($website_referer != "http://www.google.com") { echo 'None'; } else { echo 'Google Referer'; }

?>

example: http://www.google.com/search.php .... = echo 'Google Referer';
i try http://www.google.com* but is not working ...

can someone tell me how i can fix this command

thanks
ZoC is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 04-10-2010, 08:53 AM Re: Help With $_SERVER['HTTP_REFERER']
tripy's Avatar
Do not try this at home!

Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
http://www.php.net/manual/en/function.strpos.php

PHP Code:
$website_referer $_SERVER['HTTP_REFERER'];
if(
strpos($website_referer 'http://www.google.')!==FALSE){
  
//comes from a Google domain


__________________
Only a biker knows why a dog sticks his head out the window.
tripy is offline
Reply With Quote
View Public Profile Visit tripy's homepage!
 
Old 04-10-2010, 10:03 AM Re: Help With $_SERVER['HTTP_REFERER']
ZoC
Skilled Talker

Posts: 68
Trades: 0
thanks but i fix aready with this command

<?php
if (preg_match("~^http://www.google.com/~i", $_SERVER['HTTP_REFERER']))
{
echo 'Referer Google";
} else {
echo 'Referer None";
}
ZoC is offline
Reply With Quote
View Public Profile
 
Old 04-10-2010, 03:27 PM Re: Help With $_SERVER['HTTP_REFERER']
tripy's Avatar
Do not try this at home!

Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
Works too, but regexp are a bit overkill for something like this IMHO.
__________________
Only a biker knows why a dog sticks his head out the window.
tripy is offline
Reply With Quote
View Public Profile Visit tripy's homepage!
 
Old 04-10-2010, 03:28 PM Re: Help With $_SERVER['HTTP_REFERER']
nayes84's Avatar
Extreme Talker

Latest Blog Post:
Difference between ASP And JSP
Posts: 232
Name: John
Location: Tokyo
Trades: 0
Quote:
Originally Posted by ZoC View Post
thanks but i fix aready with this command

<?php
if (preg_match("~^http://www.google.com/~i", $_SERVER['HTTP_REFERER']))
{
echo 'Referer Google";
} else {
echo 'Referer None";
}
note google has many country domains like google.co.uk, google.fr and more. with your way you'll be only able to check the .com version.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE

if(I'm("Helpful")) Add_Talkupation("nayes84");
nayes84 is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Help With $_SERVER['HTTP_REFERER']
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 1.50939 seconds with 12 queries