| | #1 |
| Warrior Member Join Date: 2013
Posts: 25
Thanks: 53
Thanked 4 Times in 4 Posts
|
I think an answer to this question will likely help many folks on the forum BTW: I have tried to search the forum and Google long before posting this ![]() My scenario is this:
If you are still with me, thank you. This is difficult to explain in a concise manner. ![]() I am planning to use <? echo $_GET['id'] ?> to insert the promoter's username into all of the links but if someone comes to the site directly, I want to have the link automatically rotate through my downline's usernames, thus helping everyone get more traffic. I am sure I am not the only person to have thought of this, I just haven't been able to track it down, specifically the rotator aspect. Does anyone care to take a crack at it? Thanks in advance! Mark |
| |
| | #2 |
| Warrior Member Join Date: 2013
Posts: 25
Thanks: 53
Thanked 4 Times in 4 Posts
|
Maybe this will make the rotator part easier to understand, manage and implement:
Something like: <?php $TEAMMATE = "<? $_GET['id'] ?>"; ?> which would then allow <a href="insert domain name here/<?php echo $TEAMMATE; ?>" rel="nofollow" target="_blank"> In other words: If someone goes to the site via: domain/?id=TEAMMATE all of the links going to the company will give TEAMMATE credit If someone goes to the site directly (without an affiliate link), the links will all be served up with URL rotator link that will rotate through my team's usernames and helping everyone on my team more traffic than they would have had otherwise = everyone wins! |
| |
| | #3 |
| PHP ninja War Room Member Join Date: 2011 Location: Denver
Posts: 124
Thanks: 13
Thanked 27 Times in 25 Posts
|
<? if($_GET['id'] > 0) { $TEAMMATE = $_GET['id']; }else{ //include your url rotator here } ?> |
|
The best path to prosperity is free market capitalism!
| |
| |
| The Following User Says Thank You to kevbo22 For This Useful Post: |
| | #4 |
| Warrior Member Join Date: 2013
Posts: 25
Thanks: 53
Thanked 4 Times in 4 Posts
|
Thanks for the quick reply, kevbo22. I am pretty new to working with PHP so thank you for your patience: Can you give me an example of how to implement this? ie: Is your code to be placed in the HEAD tags? <? if($_GET['id'] > 0) { $TEAMMATE = $_GET['id']; }else{ //include your url rotator here URL-ROTATOR dot COM } ?> and being as originally my links have been: "domain dot com/<?php echo $TEAMMATE; ?>" to allow their ID to convert the links and give them credit, would there be a way to have the links go to: URL/TEAMMATE link (IF they provided a "?id=TEAMMATE") OR ROTATOR URL (IF the reader came to the site directly) I hope this makes sense. I truly appreciate your help. I'm designing this as an effort to "pay it forward" as much as I can. Thanks, Mark |
| |
| | #5 |
| Advanced Warrior War Room Member Join Date: 2006 Location: USA
Posts: 1,907
Thanks: 236
Thanked 1,377 Times in 676 Posts
|
I would use isset instead of > 0 <?php if(isset($_GET['id'])) { $TEAMMATE = $_GET['id']; }else{ // rotator code here } ?> Also, you should sanitize your $TEAMMATE value before you do anything with it, otherwise you're opening yourself up to all kinds of potentially nasty stuff (XSS attacks, etc). Using htmlspecialchars is a good start, and will protect you from most types of basic attacks. $TEAMMATE = htmlspecialchars($TEAMMATE, ENT_QUOTES); As per the rotator part, the easiest way (by far) to do it would be to assign each of your teammate's an ID number, and then rotate through them randomly (which should work out to be fairly even over the long run). For example, if you have 3 teammate's, and their referral ID's are Member1, Member2, Member3, etc., then you can do something like this... $number = (rand(1,3); $TEAMMATE = "Member" . $number; echo $TEAMMATE; If you'd rather not go the random route, then you would have to keep track of each of your teammate's referral count in either a database or a flat file, then loop through each teammate in the database whenever someone visits the site without an aff link. That would involve a lot more code than the 'random' option though, and I'd definitely recommend hiring someone to code that part if you're new to PHP / MySQL. |
| | |
| |
| The Following 2 Users Say Thank You to Brandon Tanner For This Useful Post: |
| | #6 |
| Warrior Member Join Date: 2013
Posts: 25
Thanks: 53
Thanked 4 Times in 4 Posts
|
Brandon, that sounds great. To clarify: <head> <?php if(isset($_GET['id'])) { $TEAMMATE = $_GET['id']; }else{ //rotator dot com } ?> </head> And the link would be: <body> company dot com/<? echo $_GET['id'] ?> </body> Not sure yet how to implement the: $TEAMMATE = htmlspecialchars($TEAMMATE, ENT_QUOTES); ...but I really appreciate you bringing that up |
| |
| | #7 |
| Advanced Warrior War Room Member Join Date: 2006 Location: USA
Posts: 1,907
Thanks: 236
Thanked 1,377 Times in 676 Posts
|
I would put the initial PHP code block very first thing in the document (before the <html> tag). Then you can put the echo code anywhere you need it in the body. As per how to implement htmlspecialchars, just insert the htmlspecialchars line right after you grab the $TEAMMATE value from $_GET... <?php if(isset($_GET['id'])) { $TEAMMATE = $_GET['id']; $TEAMMATE = htmlspecialchars($TEAMMATE, ENT_QUOTES); } else { // rotator code here } ?> Basically, all the htmlspecialchars line does is sanitize (encode) any quotes found in the $TEAMMATE value (because a malicious user would normally need to use quotes to facilitate a XSS attack, yet a legitimate affiliate ID will not normally contain quotes). In the odd case you DO want to be able to use quotes as part of the affiliate ID, then you would simply decode that value whenever you need it (see this). |
| | |
| |
| The Following User Says Thank You to Brandon Tanner For This Useful Post: |
|
| Bookmarks |
| Tags |
| php, question, simple |
| |