Calling all genius PHP dudes...

by 9 replies
11
******************************
Edit: SOLVED because caesargus
is FRIGGIN AWESOME.

******************************

I totally suck at tech stuff.

But there's a ton of info you can find
about how to "echo" affiliate id's into
aWeber custom fields...

And... I can get it to work on STATIC
PAGES sooo easily...

But when it comes to a blog, it doesn't
work and I've been trying to figure it
out for over 6 hours.

I never want to look at a computer
again.

Do you know if there is a solution out
there that I'm missing?

Marc
#programming #calling #dudes #genius #php
  • Hi Marc,

    If I understand correctly, you're wanting your subscription forms to also tag subscribers with an affiliate referral code. You've figured out how to do that when you are programming a page, but not when you are posting pages through blog software.

    My guess is that you're publishing these forms through some sort of "content management system" (like posting them to a Wordpress page perhaps?) So the likely trouble is that these pages created through the CMS do not process any PHP code.

    If you are in fact using Wordpress, there are plugins that will interpret PHP code. WordPress › PHP Execution WordPress Plugins

    If I've misunderstood, please do explain further.

    -Ryan
    • [1] reply
    • Yeah I'm using Wordpress and there are
      PHP plugins for the posts, but the particular
      script I'm using sets the session id using
      $redirect before loading the header.

      (I don't know if that makes sense or not.)

      I haven't figured out how I'll be able to set
      the referrer before the php headers are
      "sent," and it's making it totally useless.

      I've thought of a work around which is
      to just direct them to the blog AFTER
      they've subscribed on the home page.

      That's the best I can figure and what I'm
      going to do to save time.

      Thanks if you think of anything.
  • No, that does not make sense .. though redirecting to a thank-you page is not all that bad either
    • [1] reply
    • You'll probably need to use Javascript to set the ID.
  • Well, the referrer is set by the browser and is not set by you. Basically the referrer is if someone came through a link then the referer is the page that sent them to you. So for example, someone performs a google search, and brings up one of your pages in the result list, and then goes to your page, then the referer is set to google's search results page.

    If the user is clicking from an email or the user opens a new browser to get to your page, then the referer is not set.

    Redirecting before headers are set is something that occurs normally within php. PHP cannot perform a server side redirect if any information has already been sent to the browser. There are other ways to perform the redirect if the headers are sent, but that does not seem to be your issue.

    Setting the session id before the user actually starts interacting with you, it appears that your script is trying to log a cookie onto your machine, so it can remember any settings that your user performs during that user's visit. If you are using firefox, you can go to preferences -> security -> remove individual cookies -> type in your site name and you should see at least one entry there for your site's cookies. If you're really curious as to what the script is using the cookie for, look for things that call the word $_SESSION or $_COOKIE. These values will be passed around your user's visit (search the entire site structure, the variables could be anywhere in the codebase), to set various things, like user's first name, user's color preferences, etc.

    Without knowing more detail about your script, your site, etc. I'm not sure what other information you might find helpful, so I'll end my post here. But feel free to PM me if you would like additional assistance.
  • You need to use javascript....
  • you could pass it in the url bar

    url.com?id=943i9443

    then use $_GET[id]; to pull the id from the redirected url.
    • [1] reply
    • Oh OK. I get what you're saying. I probably used the word "referrer" in the wrong way.

      It does use $_SESSION actually. (I'll just show you.)

      I think I'll do that

      Yeah I tried that to do that but I can't seem to get it to work.
  • If you want to do this, you'll probably want to write it as a plugin so you can call hooks.

    function yourPHP(){
    //redirect occurs here
    }
    add_action ( 'wp', 'yourPHP');

    When running your site, it will find add_action and it will call yourPHP() when the WP hook is called. The WP hook is called before any sessions are sent. Avoid using wp_head as it is theme depended...so you've got a 50/50 shot of it sending it before the headers.

Next Topics on Trending Feed