Web coding help.

DubbDesigns
10+ year member

CarAudio.com Veteran
I am trying to create an affiliate program. I need a script that will be used with banners. How can I make the url keep a tracking tag in it, such as http://mysite.com/index.php?ref=bob

or something like that. I need to be sure that tag will stay up in the url box through all my pages. Then in my order form I need it to call that tag into the form, which I can do later. I just need to figure out if it is possible to get a tag to stay up there.

Maybe it will have something to do with sessions?

BTW: Iam using Xoops for my core.

 
Keeping it in the URL wouldn't be a good way to do it. Throw it in the URL on the first call to your script, and that would store the value as a session variable - which would eliminate having to pass the value between any and all pages. Keeping it as part of the URl for all pages is like logging in 20 different times. You should only 'log in' once, then store the parameters as a session variable or even using a cookie.

for example, if you have the url:

http://mysite.com/index.php?ref=bob

index.php would do something like this:

Code:
#startup the session
session_start();

#clear it out at first
$_SESSION["refocde"] = null;

#if they sent a ref= store it as the refcode session variable
if ($_REQUEST["ref"] != null) {
    $_SESSION["refcode"] = $_REQUEST["ref"];
}
and then the final form that needs to access it would do something like:

Code:
#startup the session
session_start();

#grab the list of fields; if refcode session var is not blank, use it, other wise use a blank string
$sql_flds = "field1,field2,field3" . (($_SESSION["refcode"] != null) ? ",refcode":"");
$sql_vals = $_POST["formfield1"] . "," . $_POST["formfield2"] . "," . $_POST["formfield3"] . (($_SESSION["refcode"] != null) ? "," . $_SESSION["refcode"]:"");

#complete the statement
$sql = "insert into formsubmissions($sql_flds) values($sql_vals);";
 
Not sure exactly, but I'm positive you can find something over at http://www.hotscripts.com just in case you didn't know about this place already..
Yea, I already checked there, nothing that caught my interest. Thanks anways tho.

Keeping it in the URL wouldn't be a good way to do it. Throw it in the URL on the first call to your script, and that would store the value as a session variable - which would eliminate having to pass the value between any and all pages. Keeping it as part of the URl for all pages is like logging in 20 different times. You should only 'log in' once, then store the parameters as a session variable or even using a cookie.

for example, if you have the url:

http://mysite.com/index.php?ref=bob

index.php would do something like this:

Code:

#startup the session

session_start();

#clear it out at first

$_SESSION["refocde"] = null;

#if they sent a ref= store it as the refcode session variable

if ($_REQUEST["ref"] != null) {

$_SESSION["refcode"] = $_REQUEST["ref"];

}

and then the final form that needs to access it would do something like:

Code:

#startup the session

session_start();

#grab the list of fields; if refcode session var is not blank, use it, other wise use a blank string

$sql_flds = "field1,field2,field3" . (($_SESSION["refcode"] != null) ? ",refcode":"");

$sql_vals = $_POST["formfield1"] . "," . $_POST["formfield2"] . "," . $_POST["formfield3"] . (($_SESSION["refcode"] != null) ? "," . $_SESSION["refcode"]:"");

#complete the statement

$sql = "insert into formsubmissions($sql_flds) values($sql_vals);";
Yea, that seems like it should work. Thanks

 
Activity
No one is currently typing a reply...

About this thread

DubbDesigns

10+ year member
CarAudio.com Veteran
Thread starter
DubbDesigns
Joined
Location
KY
Start date
Participants
Who Replied
Replies
5
Views
250
Last reply date
Last reply from
DubbDesigns
IMG_20260506_140749.jpg

74eldiablo

    May 22, 2026
  • 0
  • 0
design.jpeg

WNCTracker

    May 22, 2026
  • 0
  • 0

New threads

Top