Hi ayushphant,
I went ahead and fixed up your post for you so the code displays properly (and tweaked it a bit).
To add to the discussion, something similar can be accomplished with .htaccess, however, tracking would be sketchy.
Add the following line to your .htaccess file:
Code:
Redirect 302 /affiliatename http://link.to.affiliate/
Then, whenever you wish to redirect people to your affiliate link, just use
www.yoursite.com/affiliatename (the directory doesn't even need to exist for this method to work).
I will offer this one caveat: make sure to stay on top of managing your affiliate redirects however you do it. It's very easy to begin losing track of them/keeping them organized when you have a lot of them. (I speak from experience. LOL)
~ Teli