| | #1 |
| Phil Raymond Join Date: 2010 Location: Toronto, Canada
Posts: 22
Thanks: 1
Thanked 1 Time in 1 Post
|
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 |
| |
| | #2 |
| HyperActive Warrior Join Date: 2011 Location: Edmonton, Alberta
Posts: 120
Thanks: 0
Thanked 25 Times in 23 Posts
|
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. |
| |
| The Following User Says Thank You to unnatural For This Useful Post: |
| | #3 |
| Phil Raymond Join Date: 2010 Location: Toronto, Canada
Posts: 22
Thanks: 1
Thanked 1 Time in 1 Post
|
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'; } ?> |
| |
| | #4 |
| HyperActive Warrior Join Date: 2011 Location: Edmonton, Alberta
Posts: 120
Thanks: 0
Thanked 25 Times in 23 Posts
|
Glad I could help |
| |
| | #5 |
| Warrior Member Join Date: 2010
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
|
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?
|
| |
| | #6 |
| Warrior Extremist Join Date: 2012 Location: Orange, CA
Posts: 38
Thanks: 0
Thanked 4 Times in 4 Posts
|
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 | |
| |
|
| Bookmarks |
| Tags |
| based, dynamic, html, php, show, text, twitter, url, user |
| |