More PHP help needed

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • BiggleJones
    Confirmed User
    • Dec 2002
    • 2276

    #1

    More PHP help needed

    I am trying to implement the CCBill ID cookie code ( like http://www.spunkycash.com/ ) into my affiliate site. I have the code working on individual pages, but the variable/cookie clears everytime I switch pages. Any help on this would be awesome and thanks in advance:

    <?
    $ccbillid = "".$_POST['ccbillinput']."";
    $cookie_life = time() + 31536000;
    setcookie('ccbillid', $ccbillid, $cookie_life, '/', '.69gs.com');
    $_COOKIE["ccbillid"] = $ccbillid;

    if (!$_COOKIE["ccbillid"]){$ccbilloutput = "XXXXXX"; }
    else {$ccbilloutput = $_COOKIE["ccbillid"]; }

    if(isset($_COOKIE['ccbillinput'])) $ccbillid = $_COOKIE['ccbillinput'];
    if(isset($_POST['ccbillinput'])) $ccbillid = $_POST['ccbillinput'];
    ?>
  • Due
    Confirmed User
    • Mar 2001
    • 3620

    #2
    Check first before your setcookie if a cookie exists.
    Most likely only the FIRST page they see is through POST $_POST['ccbillinput'] so on the next page they go to the POST command will be blank and you will be setting a blank cookie.
    I buy plugs
    Skype: Due_Global
    /Due

    Comment

    • AcidMax
      Confirmed User
      • May 2002
      • 1827

      #3
      Code:
      setcookie('ccbillid', $ccbillid, $cookie_life, '/', '.69gs.com');
      $_COOKIE["ccbillid"] = $ccbillid;
      Without testing the problem could be the code above. Just try setting it on one page, and then just checking to see if it exists.

      Code:
      if(!isset($_COOKIE['ccbillid']))
      {
         setcookie(...);
      }
      
      echo $_COOKIE['ccbillid'];
      Latest MMA news. http://www.mmawrapup.com

      Comment

      • MickeyG
        Confirmed User
        • May 2004
        • 4134

        #4
        add session_start(); to each pg.

        Comment

        • AcidMax
          Confirmed User
          • May 2002
          • 1827

          #5
          Originally posted by MickeyG
          add session_start(); to each pg.
          He is not setting a session variable.
          Latest MMA news. http://www.mmawrapup.com

          Comment

          • BiggleJones
            Confirmed User
            • Dec 2002
            • 2276

            #6
            Thanks AcidMax for the suggestion...still cant get it working. Anyone else have any ideas?

            Comment

            • Alky
              Confirmed User
              • Apr 2002
              • 5651

              #7
              maybe change:
              PHP Code:
              setcookie('ccbillid', $ccbillid, $cookie_life, '/', '.69gs.com'); 
              
              to:
              PHP Code:
              setcookie('ccbillid', $ccbillid, $cookie_life, '/', '69gs.com'); 
              
              that period in the domain might be throwing it off

              just a guess i didnt test it.

              Comment

              • Alky
                Confirmed User
                • Apr 2002
                • 5651

                #8
                Originally posted by MickeyG
                add session_start(); to each pg.
                and don't do this.

                Comment

                • BiggleJones
                  Confirmed User
                  • Dec 2002
                  • 2276

                  #9
                  I didnt even notice that period, but I took it out and still same problem. Ive been trying to figrue this out for over a week now, and its the only thing left to do so I can re-launch my affiliate program.

                  UUUUggghhhhh

                  Comment

                  • Alky
                    Confirmed User
                    • Apr 2002
                    • 5651

                    #10
                    you have that code on every page?

                    Comment

                    • Alky
                      Confirmed User
                      • Apr 2002
                      • 5651

                      #11
                      and its working fine for me i browsed from page to page, also closed my browser and came back... still good on my end

                      Comment

                      • BiggleJones
                        Confirmed User
                        • Dec 2002
                        • 2276

                        #12
                        Originally posted by Alky
                        you have that code on every page?
                        yea....Im just having the form post to whatever page they are on.

                        Should I just have the form post to one php page instead? And if so, what code should I put in the individual pages to call that variable?

                        Comment

                        • BiggleJones
                          Confirmed User
                          • Dec 2002
                          • 2276

                          #13
                          Originally posted by Alky
                          and its working fine for me i browsed from page to page, also closed my browser and came back... still good on my end
                          hmmm....am I calling it wrong? <? print $ccbilloutput; ?>

                          Comment

                          • Alky
                            Confirmed User
                            • Apr 2002
                            • 5651

                            #14
                            Originally posted by BiggleJones
                            yea....Im just having the form post to whatever page they are on.

                            Should I just have the form post to one php page instead? And if so, what code should I put in the individual pages to call that variable?
                            if you do it this way, you will need to check if $_POST['ccbillinput'] is set, otherwise it is going to run your setcookie every time

                            Comment

                            • BiggleJones
                              Confirmed User
                              • Dec 2002
                              • 2276

                              #15
                              Originally posted by Alky
                              if you do it this way, you will need to check if $_POST['ccbillinput'] is set, otherwise it is going to run your setcookie every time
                              Got ICQ or AIM?

                              AIM - Biggle Jones

                              ICQ - 291596343

                              Comment

                              • BiggleJones
                                Confirmed User
                                • Dec 2002
                                • 2276

                                #16
                                THIS JUST IN.....ALKY IS THE MAN (even with his Persian mullet)

                                Comment

                                Working...