PHP Help - Easy but not for me.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • infectd
    Confirmed User
    • Dec 2002
    • 1122

    #1

    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
    #1 Adult Content Provider
    • Jul 2003
    • 11577

    #2
    you post an ad in craigslist, you'll get 100 resumes :-)
    [email protected]
    ICQ : 494-353-230
    Follow WWC on Twitter CLICK HERE!


    " CONTENT PROVIDER OF THE YEAR! " ~ 2007 , 2008 & 2009 XBIZ AWARDS WINNER!

    Comment

    • borked
      Totally Borked
      • Feb 2005
      • 6284

      #3
      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!

      For coding work - hit me up on andy // borkedcoder // com
      (consider figuring out the email as test #1)



      All models are wrong, but some are useful. George E.P. Box. p202

      Comment

      • mrkris
        Confirmed User
        • May 2005
        • 2737

        #4
        Originally posted by borked
        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';

        PHP-MySQL-Rails | ICQ: 342500546

        Comment

        • borked
          Totally Borked
          • Feb 2005
          • 6284

          #5
          Originally posted by mrkris
          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....

          For coding work - hit me up on andy // borkedcoder // com
          (consider figuring out the email as test #1)



          All models are wrong, but some are useful. George E.P. Box. p202

          Comment

          • infectd
            Confirmed User
            • Dec 2002
            • 1122

            #6
            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

            Comment

            • darksoul
              Confirmed User
              • Apr 2002
              • 4997

              #7
              Code:
              <a href="http://www.gotosite.com/?<?echo $_REQUEST['referralCode']; ?>">See the tour</a>
              1337 5y54|)m1n: 157717888
              BM-2cUBw4B2fgiYAfjkE7JvWaJMiUXD96n9tN
              Cambooth

              Comment

              • borked
                Totally Borked
                • Feb 2005
                • 6284

                #8
                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>";

                For coding work - hit me up on andy // borkedcoder // com
                (consider figuring out the email as test #1)



                All models are wrong, but some are useful. George E.P. Box. p202

                Comment

                • borked
                  Totally Borked
                  • Feb 2005
                  • 6284

                  #9
                  Originally posted by darksoul
                  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....

                  For coding work - hit me up on andy // borkedcoder // com
                  (consider figuring out the email as test #1)



                  All models are wrong, but some are useful. George E.P. Box. p202

                  Comment

                  • infectd
                    Confirmed User
                    • Dec 2002
                    • 1122

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

                    Comment

                    • infectd
                      Confirmed User
                      • Dec 2002
                      • 1122

                      #11
                      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.

                      Comment

                      • borked
                        Totally Borked
                        • Feb 2005
                        • 6284

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


                        php.net is your friend ;)

                        For coding work - hit me up on andy // borkedcoder // com
                        (consider figuring out the email as test #1)



                        All models are wrong, but some are useful. George E.P. Box. p202

                        Comment

                        • ForteCash
                          Confirmed User
                          • Feb 2006
                          • 3278

                          #13
                          www.reecemarketing.com <---PHP Pro's

                          NO PILLS - NO EXPENSIVE STRETCHERS - JUST REAL EXERCISES THAT WORK!
                          "Upsell Your Members The Top Penis Enlargement Site!"
                          Link Exchanges & Traffic Trades www.penilefitness.com/links/
                          *ICQ: 63935693* $50 per trial with www.ForteCash.com

                          Comment

                          • infectd
                            Confirmed User
                            • Dec 2002
                            • 1122

                            #14
                            I get an error about modifying header information

                            Comment

                            • infectd
                              Confirmed User
                              • Dec 2002
                              • 1122

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

                              Comment

                              • borked
                                Totally Borked
                                • Feb 2005
                                • 6284

                                #16
                                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.

                                For coding work - hit me up on andy // borkedcoder // com
                                (consider figuring out the email as test #1)



                                All models are wrong, but some are useful. George E.P. Box. p202

                                Comment

                                • infectd
                                  Confirmed User
                                  • Dec 2002
                                  • 1122

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

                                  Comment

                                  • MaddCaz
                                    Confirmed User
                                    • Mar 2006
                                    • 9483

                                    #18
                                    this shit foe my KIDS!!!!!

                                    BigCocks.com -
                                    MatureWomen.com -
                                    Tranny.com -
                                    DrunkGirls.com -
                                    TeenGirls.com -
                                    MonsterCock.com and
                                    many more... Click
                                    here to see them all!

                                    Comment

                                    • borked
                                      Totally Borked
                                      • Feb 2005
                                      • 6284

                                      #19
                                      Originally posted by infectd
                                      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

                                      For coding work - hit me up on andy // borkedcoder // com
                                      (consider figuring out the email as test #1)



                                      All models are wrong, but some are useful. George E.P. Box. p202

                                      Comment

                                      • infectd
                                        Confirmed User
                                        • Dec 2002
                                        • 1122

                                        #20
                                        I got it working, but want to say thanks

                                        Comment

                                        • pornpf69
                                          Too lazy to set a custom title
                                          • Jun 2004
                                          • 15782

                                          #21
                                          interesting thread....

                                          Comment

                                          • Varius
                                            Confirmed User
                                            • Jun 2004
                                            • 6890

                                            #22
                                            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..)
                                            Skype variuscr - Email varius AT gmail

                                            Comment

                                            • borked
                                              Totally Borked
                                              • Feb 2005
                                              • 6284

                                              #23
                                              Originally posted by Varius
                                              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

                                              For coding work - hit me up on andy // borkedcoder // com
                                              (consider figuring out the email as test #1)



                                              All models are wrong, but some are useful. George E.P. Box. p202

                                              Comment

                                              • V_RocKs
                                                Damn Right I Kiss Ass!
                                                • Nov 2003
                                                • 32448

                                                #24
                                                I like nerd fights...

                                                Comment

                                                Working...