GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Fucking Around & Business Discussion (https://gfy.com/forumdisplay.php?f=26)
-   -   PHP Help - Easy but not for me. (https://gfy.com/showthread.php?t=670811)

infectd 10-26-2006 11:05 PM

PHP Help - Easy but not for me.
 
I need to capture a session variable from a URL. This is so basic its embarassing.

"In addition to capturing the referralCode and retaining it as a session variable, you will also need to include logic in your download link as:

IF sessionVar ?referralCode? NOT null
THEN DownloadLink = http://www.myurlhere.com?referralCode=<referralCode>
ELSE DownloadLink = http://www.myurlhere.com (or, you could go with another referralCode - a generic one"

What I've been reading is that I need to set a cookie and then drop some php. Any help here? Even if you send me to a working exmaple code I can figure it out.

WWC 10-26-2006 11:16 PM

you post an ad in craigslist, you'll get 100 resumes :-)

borked 10-26-2006 11:21 PM

it depends how the session id is passed in the URL...

eg
index.php?sid=<sessionid>
then your session variable name is 'sid'

I'm guessing the session id is the 'referralCode', in which case:

Code:

function check_sess($sid, $refCode) {
  if ($sid) {
    if($sid == $refCode) return TRUE;
    else return FALSE;
  }else return FALSE;
}

// check session and give link
if(check_sess($_GET['sid'])) print"<referral code link here>";
else print"<non-referred link>";

not sure if that's what you were after!

mrkris 10-26-2006 11:24 PM

Quote:

Originally Posted by borked (Post 11164873)
it depends how the session id is passed in the URL...

eg
index.php?sid=<sessionid>
then your session variable name is 'sid'

I'm guessing the session id is the 'referralCode', in which case:

Code:

function check_sess($sid, $refCode) {
  if ($sid) {
    if($sid == $refCode) return TRUE;
    else return FALSE;
  }else return FALSE;
}

// check session and give link
if(check_sess($_GET['sid'])) print"<referral code link here>";
else print"<non-referred link>";

not sure if that's what you were after!

Why not just:

Code:

echo empty($_REQUEST[sid']) ? 'foo' : 'bar';

borked 10-26-2006 11:48 PM

Quote:

Originally Posted by mrkris (Post 11164886)
Why not just:

Code:

echo empty($_REQUEST[sid']) ? 'foo' : 'bar';


because I was under the impression that the refCode was the session id, and so the function gave more flexability as to what to do with it....

infectd 10-27-2006 07:13 AM

hmm I know the end of my urls im sending out have ?referralCode=XXXX
where XXXX being unique ID's

so it has to read from the url they come in on and keep it while they browse around until they hit the download link.

So I dont think the code above will work per say.. like that one is checking to see if they have refcode in their link.. I may be wrong too and it might be what I need haha :P

darksoul 10-27-2006 07:19 AM

Code:

<a href="http://www.gotosite.com/?<?echo $_REQUEST['referralCode']; ?>">See the tour</a>

borked 10-27-2006 07:24 AM

ah - so the surfer comes in with referralCode=xxxx and you want to send them out with the same?
Then, yup, store the referral code in a session cookie and collect it on the way out....
Code:

coming in:
if(!empty($_GET['referralCode'])) setcookie("referralCode", $_GET['referralCode']);

goin out:
if(isset($_COOKIE['referralCode'])) print"<a href=\"http://somedomain.com/index.php?referralCode=".$_COOKIE['referralCode']."\">Now click away</a>";
else print"<a href=\"http://somedomain.com/index.php\">Now click away</a>";


borked 10-27-2006 07:25 AM

Quote:

Originally Posted by darksoul (Post 11166692)
Code:

<a href="http://www.gotosite.com/?<?echo $_REQUEST['referralCode']; ?>">See the tour</a>

he needs to keep the refCode while the surfer surfs around his site. Cookie it, or he'll have to pass the blasted thing around as a getvar on every internal link....

infectd 10-27-2006 11:54 AM

So if I add that into the header of my site its just going to work?

infectd 10-27-2006 11:56 AM

it prints a link for them, I need it to attach to a download link.. oh no it will work but I duno how to set a cookie.

borked 10-27-2006 11:58 AM

setcookie("referralCode", $_GET['referralCode'])


php.net is your friend ;)

ForteCash 10-27-2006 12:02 PM

www.reecemarketing.com <---PHP Pro's :thumbsup

infectd 10-27-2006 01:41 PM

I get an error about modifying header information

infectd 10-27-2006 01:54 PM

I added <?php ob_start(); ?> to the top and its working for now.

borked 10-27-2006 02:03 PM

add the set cookie before ANY header information is sent, ie the very first thing on the page, before <html>

Or, like you found, suppress headers being sent by putting everything in an output buffer.

This is all very basic stuff, like you know, and it's great you're taking your first steps to programming, but when things get a bit too much, don't be afraid to pay someone for help...
we don't cost a lot.

Good luck and continuation.

infectd 10-27-2006 04:05 PM

I tried to add you on icq and im getting an error can you add me 208250960 Thanks

MaddCaz 10-27-2006 04:06 PM

this shit foe my KIDS!!!!!

borked 10-27-2006 04:18 PM

Quote:

Originally Posted by infectd (Post 11170372)
I tried to add you on icq and im getting an error can you add me 208250960 Thanks

sent you a message - off for zzzzzs

infectd 10-27-2006 04:35 PM

I got it working, but want to say thanks

pornpf69 10-27-2006 04:38 PM

interesting thread....

Varius 10-27-2006 05:06 PM

Just an FYI,

If you prefer a non-cookie approach you can also modify your php.ini to enable trans_sid (transparent session id), and then it will automatically append your session id to all urls (unless those called by javascript, which you'll still have to add manually - or forms, etc..)

borked 10-28-2006 01:38 AM

Quote:

Originally Posted by Varius (Post 11170651)
Just an FYI,

If you prefer a non-cookie approach you can also modify your php.ini to enable trans_sid (transparent session id), and then it will automatically append your session id to all urls (unless those called by javascript, which you'll still have to add manually - or forms, etc..)

I didn't know that - great info, thx :thumbsup

V_RocKs 10-28-2006 03:09 AM

I like nerd fights...


All times are GMT -7. The time now is 03:56 PM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123