1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

How to $_GET a variable with spaces in it

Discussion in 'PHP' started by MrLeN, Nov 13, 2013.

  1. #1
    I am using an aweber form to pass user data to my website.

    aweber is passing a viaraible with a space in it, which is showing up in the URL like this:

    &custom%20affid=3

    I ahve no control over this, so I can't use urlencode or anything...

    ..but for hours I ahve been trying to work out how to $_GET that variable..

    ..but I can't. I am out of ideas.

    Can anyone help me?
     
    Solved! View solution.
    MrLeN, Nov 13, 2013 IP
  2. #2
    
    $_GET['custom_affid']
    
    PHP:
    ... should do the trick.
     
    nico_swd, Nov 13, 2013 IP
    sarahk and Vooler like this.
  3. MrLeN

    MrLeN Well-Known Member

    Messages:
    406
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    120
    #3
    Never mind, I figured out a solution:

    
    <?php
    if (strpos($_SERVER['QUERY_STRING'],'custom%20affid') !== false) {
        $new_string = str_replace ('custom%20affid','custom_affid', $_SERVER['QUERY_STRING']);
            header('Location: thanks-confirmed.php?'.$new_string.'');
    }
    ?>
    
    Code (markup):
    Echo the custom field:

    
    <?php 
    echo $_GET['custom_affid'];
    ?>
    
    Code (markup):
     
    MrLeN, Nov 13, 2013 IP
  4. MrLeN

    MrLeN Well-Known Member

    Messages:
    406
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    120
    #4

    You are KIDDING me!!??

    I just spent 4 hours crying because it wouldn't work.. and I ended up having to write all that code..

    ..and you're telling me all I had to do was add an underscore?

    Ok, that's enough internet for me today.

    I am going to go and scream myself to sleep...

    *but thanks for replying.
     
    MrLeN, Nov 13, 2013 IP
    PoPSiCLe likes this.
  5. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #5
    PoPSiCLe, Nov 13, 2013 IP