Register Advertise with usHelp Desk Today's Posts Search

Closed Thread
Thread Tools Search this Thread
Unread 7th Sep 2011, 08:37 AM   #1
Phil Raymond
 
philraymond's Avatar
 
Join Date: 2010
Location: Toronto, Canada
Posts: 22
Thanks: 1
Thanked 1 Time in 1 Post
Default
Show text based on which url the user came from
Share on: 
fb share twitter share gplus share more share

I've been searching for this, but I can't figure out what to search for.

I'd like to have some php code to dynamically display some html to someone if they come from, say, twitter.

Anyone know how to do that or if there is a good source of this info somewhere?

Thanks very much,
Phil
philraymond is offline  
Unread 7th Sep 2011, 08:47 AM   #2
HyperActive Warrior
 
unnatural's Avatar
 
Join Date: 2011
Location: Edmonton, Alberta
Posts: 120
Thanks: 0
Thanked 25 Times in 23 Posts
Default
Re: Show text based on which url the user came from
Share on: 
fb share twitter share gplus share more share

Here's some example code to get you started. You just need to check the referring site, then do something based on that information ..


<?php
$referrer = $_SERVER['HTTP_REFERER'];

if (stristr($referrer,"twitter") != FALSE)) {

echo "You came from twitter!";

}
?>


That's a basic example, and there's lots of ways to check the referrer and control the output, but that should get you started. If you need any more help just let me know.
unnatural is offline  
The Following User Says Thank You to unnatural For This Useful Post:
Unread 8th Sep 2011, 04:33 PM   #3
Phil Raymond
 
philraymond's Avatar
 
Join Date: 2010
Location: Toronto, Canada
Posts: 22
Thanks: 1
Thanked 1 Time in 1 Post
Default
Re: Show text based on which url the user came from
Share on: 
fb share twitter share gplus share more share

Thanks so much for that. I ended up using the following. Just changed the " to ' and twitter to t.co:

<?php
$referrer = $_SERVER['HTTP_REFERER'];

if (stristr($referrer,'t.co') != FALSE)) {

echo 'yada yada';

}
?>
philraymond is offline  
Unread 8th Sep 2011, 04:58 PM   #4
HyperActive Warrior
 
unnatural's Avatar
 
Join Date: 2011
Location: Edmonton, Alberta
Posts: 120
Thanks: 0
Thanked 25 Times in 23 Posts
Default
Re: Show text based on which url the user came from
Share on: 
fb share twitter share gplus share more share

Glad I could help
unnatural is offline  
Unread 3rd Apr 2012, 03:46 PM   #5
Warrior Member
 
Join Date: 2010
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default
Re: Show text based on which url the user came from
Share on: 
fb share twitter share gplus share more share

Hello guys. I'm using wordpress and need to do something similar. How can I show text based on current url. For example: How to show a message base n this url struture: acne-scars.versatileinformationportal.com. When a site visitor is checking any post n this subdomain how can I show an specific message for them. Any help?
IvanJaquez is offline  
Unread 3rd Apr 2012, 04:37 PM   #6
Warrior Extremist
 
xrampage16's Avatar
 
Join Date: 2012
Location: Orange, CA
Posts: 38
Thanks: 0
Thanked 4 Times in 4 Posts
Default
Re: Show text based on which url the user came from
Share on: 
fb share twitter share gplus share more share

If you are using Drupal, you can check what the current url is by checking out the contents of $_GET['q']

If you are using another content management system, you can probably do something similar by checking out the contents of $_GET, and seeing if the url is stored inside of there, or getting the contents of $_SERVER as "unnatural" suggests.

Developer and Admin for Komputer King LLC hosting - Offering lightning fast web hosting and Quality Backlink Building
xrampage16 is offline  
Closed Thread


Bookmarks

Tags
based, dynamic, html, php, show, text, twitter, url, user


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




All times are GMT -6. The time now is 11:04 PM.