Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

 

Register GFY Rules Calendar
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >
New Webmasters ask "How-To" questions here. This is where other fucking Webmasters help.

 
Thread Tools
Old 06-16-2011, 03:06 PM   #1
officemike
Confirmed User
 
officemike's Avatar
 
Industry Role:
Join Date: Apr 2011
Location: Paso Robles, CA
Posts: 127
Appending links with PHP

Fuck the paid applications out there that do this, I want to do this in-house, you know, for free:

I am looking for a resource/documentation on using form action on my affiliate site that allows affiliates to enter their affiliate ID, and have a PHP function that can append the affiliate links with the user's ID as a cookie.

I've googled it, yes, but I might as well google "help"--I get that many irrelevant results. I'm just on the cusp of figuring out with PHP, I just need a push in the right direction.
officemike is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook
Old 06-16-2011, 03:27 PM   #2
robber
Web Developer
 
Industry Role:
Join Date: Jan 2011
Location: UK
Posts: 264
ok you want something like:

Put this at the top of your page:
Code:
<?php session_start(); #<-- Must be first line
if(!empty($_POST['id'])){$_SESSION['affid'] = $_POST['id'];} #<-- Sets the affiliate id
{$affid = $_SESSION['affid'];} #<-- assign affiliate id
if(empty($_SESSION['affid'])){$affid = "xxxxxx";} #<-- add a default value
 ?>
when you have your input box have your form set like:
Code:
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<input type="text" name="id" value="<?php echo $affid; ?>">
</form>
Then for each of your links just add the below code where ever you would like to have the affiliate id shown:
Code:
<?php echo $affid; ?>
Hope this helps, if you need any more help please feel free to e-mail me: rob [at] foxydrop [dot] com or reply here

Rob

Last edited by robber; 06-16-2011 at 03:32 PM..
robber is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook
Old 06-30-2011, 06:14 PM   #3
officemike
Confirmed User
 
officemike's Avatar
 
Industry Role:
Join Date: Apr 2011
Location: Paso Robles, CA
Posts: 127
Thanks Robber!

Working this into my site. I forgot to mention it's a wordpress site, so perhaps a little more tricky working with the loop. My content is searchable, which puts the search results on a different page than the index. Can I place the code in my header, which appears on every page regardless if it's index, search, archive, etc...?


Also, does this store the id to cookies? I would like to have the user's ID cookied, so it appends the link every time the user visits, without them having to enter the id every time.

Last edited by officemike; 06-30-2011 at 06:16 PM..
officemike is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook
Old 07-01-2011, 10:34 AM   #4
robber
Web Developer
 
Industry Role:
Join Date: Jan 2011
Location: UK
Posts: 264
OK then to have this set in a cookie like you have requested you would need to change the header script to being:

Code:
<?php 
if(!empty($_POST['id'])){setcookie("affid",$_POST['id']);} #<-- Sets the affiliate id
{$affid = $_COOKIE['affid'];} #<-- assign affiliate id
if(empty($_COOKIE['affid'])){$affid = "xxxxxx";} #<-- add a default value
 ?>
This will set a cookie for the user instead of storing the value within a session on the server

Hope this helps. Please feel free to ask if you have any other questions

Rob
robber is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook
Old 07-05-2011, 03:48 PM   #5
officemike
Confirmed User
 
officemike's Avatar
 
Industry Role:
Join Date: Apr 2011
Location: Paso Robles, CA
Posts: 127
Then I would change the form action slightly as well, no?
changing from
PHP Code:
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post";">
to call a cookie instead...

PHP Code:
<form action="<?php echo $_COOKIE['affid']; ?>" method="post";">
or do I still use $_server ?

Last edited by officemike; 07-05-2011 at 03:51 PM..
officemike is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook
Old 07-07-2011, 09:53 AM   #6
robber
Web Developer
 
Industry Role:
Join Date: Jan 2011
Location: UK
Posts: 264
No you leave everything else the same as the rest is what runs the form. if you need help integrating this please drop me an e-mail: [email protected] (replace the 0's with o's) and I will go through it with you and answer any other questions you have

Kind Regards

Rob
robber is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook
Old 07-19-2011, 03:51 PM   #7
dc0ded
Confirmed User
 
dc0ded's Avatar
 
Industry Role:
Join Date: May 2011
Location: Bedworth, United Kingdom
Posts: 1,022
hey robber great job man . even I also learnt from this . thanks from my side too.
__________________
Guaranteed Adult SEO Service- Just $275 per month
dc0ded is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook
Old 07-20-2011, 01:52 AM   #8
robber
Web Developer
 
Industry Role:
Join Date: Jan 2011
Location: UK
Posts: 264
Hi Guys,

I've just looked back over what I wrote and I need to amend the header scripts just slightly. But I have also expanded on a few points raised above as well regarding processing and how to do this in a separate file

##################################################

If you are storing your affiliate ID in a session, your header script should be:

Code:
<?php session_start(); #<-- Must be first line
if(!empty($_POST['id'])){$_SESSION['affid'] = $_POST['id']; #<-- Sets the affiliate id
$affid = $_SESSION['affid'];} #<-- assign affiliate id
if(empty($_SESSION['affid'])){$affid = "xxxxxx";} #<-- add a default value
 ?>
If you are storing your affiliate ID in a cookie your header script should be:
Code:
<?php 
if(!empty($_POST['id'])){setcookie("affid",$_POST['id']); #<-- Sets the affiliate id
$affid = $_COOKIE['affid'];} #<-- assign affiliate id
if(empty($_COOKIE['affid'])){$affid = "xxxxxx";} #<-- add a default value
 ?>
The rest should stay the same, so where you want to have your input box to insert your affiliate id put in:

Code:
<form action="<?php 
echo $_SERVER['PHP_SELF']; # This will loop round to the same page, if you have a specific page you would like to direct to, just replace this whole php tag with the url/link to the page eg. "afflink.php"
 ?>" method="post">
<input type="text" name="id" value="<?php echo $affid; ?>">
</form>
If you want to process your link in an individual file your individual file should look like (You still need to have the header script in place to enable this to work):

### If Using Sessions ###
Code:
<?php
session_start(); #<-- Must be first line
if(!empty($_POST['id'])){$_SESSION['affid'] = $_POST['id']; #<-- Sets the affiliate id
header("location: #File name here#"); #put in the file name eg. index.php
exit(); #This will stop the script processing any further
?>
### If Using Cookies ###
Code:
<?php
if(!empty($_POST['id'])){setcookie("affid",$_POST['id']); #<-- Sets the affiliate id
header("location: #File name here#"); #put in the file name eg. index.php
exit(); #This will stop the script processing any further
?>
If you wanted to have a different file (one which is showing content) to be the page the user goes to after inserting their code, then just put the link in the form tags (as described above) and make sure that file has the header script in it and everything will work automatically.

Then wherever you would like to insert the affiliate code put:
Code:
<?php echo $affid; ?>
I hope this works for you, and it has covered most amendments and basic additional options for how you process the affiliate code on your site.

If you are storing your affiliate ID in a database, please contact me and I will help you write the code as every database is different in design and naming and so I wouldn't be able to cover that in this tutorial. Please send help requests to: [email protected] (please replace the 0's for o's)

Rob

Last edited by robber; 07-20-2011 at 01:58 AM.. Reason: Just a few amendments, and ironing out what I meant
robber is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook
 
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >

Bookmarks

Tags
ccbill, php



Advertising inquiries - marketing at gfy dot com

Contact Admin - Advertise - GFY Rules - Top

©2000-, AI Media Network Inc



Powered by vBulletin
Copyright © 2000- Jelsoft Enterprises Limited.