Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    New Coder
    Join Date
    Jan 2004
    Location
    Illinois
    Posts
    72
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Header and Location

    Hey,
    I have google ads on my website and in the TOC it says I can't have them on registration pages. I'm trying to create a script where if the address bar contains the word register then the ads won't show here is what I have so far:
    Code:
    <?php
    
    $urrl = header('Location:'); 
    $urrlpos = strrpos($urrl,"register");
    
    
    if ($urrlpos < 0 ) { 
    echo '<script type="text/javascript">';
    echo 'google_ad_client = "a secret";';
    echo 'google_ad_width = 728;';
    echo 'google_ad_height = 90;';
    echo 'google_ad_format = "728x90_as";';
    echo 'google_ad_channel ="";';
    echo 'google_color_border = "B4D0DC";';
    echo 'google_color_bg = "ECF8FF";';
    echo 'google_color_link = "0000CC";';
    echo 'google_color_url = "008000";';
    echo 'google_color_text = "6F6F6F";';
    echo '</script>';
    
    echo '<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>';
    
    }
    
    ?>
    How come its not working?!?!??!
    Last edited by Unknown; 05-09-2004 at 05:28 PM.

  • #2
    raf
    raf is offline
    Master Coder
    Join Date
    Jul 2002
    Posts
    6,589
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Unknown
    How come its not working?!?!??!
    Because your condition is
    if (False < 0){ etc.
    and because the first lime does a redirect to nothing
    $urrl = header('Location:');

    If you need to now if the filename contains 'register', then replace

    $urrl = header('Location:');
    $urrlpos = strrpos($urrl,"register");
    if ($urrlpos < 0 ) {

    by

    if (!strpos($_SERVER['PHP_SELF'],'register')) {
    Posting guidelines I use to see if I will spend time to answer your question : http://www.catb.org/~esr/faqs/smart-questions.html

  • #3
    New Coder
    Join Date
    Jan 2004
    Location
    Illinois
    Posts
    72
    Thanks
    2
    Thanked 0 Times in 0 Posts
    That works. But I have another problem :P. It still won't work. Now it shows the ads on all pages even the register pages. (i'm using phpBB)

  • #4
    raf
    raf is offline
    Master Coder
    Join Date
    Jul 2002
    Posts
    6,589
    Thanks
    0
    Thanked 0 Times in 0 Posts
    How come?
    I just tryed it out by creating a file with this content
    PHP Code:
    <?php
    if (!strpos($_SERVER['PHP_SELF'],'register')) {
       echo 
    'The pages name or virtual adress does not contain "register"';
    }else{
        echo 
    'The pages name or virtual adress does contain "register"';
    }
    ?>
    and then naming it testregister.php and loading it in the browser. Then renaming it to test.php an loading that in the browser. And as i expected, it worked just perfectly. So this code is perfectly capable of detecting "register" in an url (except for the domainname)

    So maybe you copied it incorrectly or the rest of your code has some bug. But with the info you give, it's impossible to say.
    Posting guidelines I use to see if I will spend time to answer your question : http://www.catb.org/~esr/faqs/smart-questions.html

  • #5
    New Coder
    Join Date
    Jan 2004
    Location
    Illinois
    Posts
    72
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Well the problem is prolly that I'm using phpBB and the only time I don't want it to show is when a person is registering. To get to the registering page a person clicks on a link and that link does this :
    profile.php?mode=register...
    So I don't know why its not working.

  • #6
    raf
    raf is offline
    Master Coder
    Join Date
    Jul 2002
    Posts
    6,589
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I already feared you'd not needed to only test against the script-adress, but also the querystring (hence i explicitily mentioned it). So if you also need to search the querystring, then it becomes

    if ((!strpos($_SERVER['PHP_SELF'],'register')) and (!strpos($_SERVER['QUERY_STRING'],'register'))) {

    but this means that a user could get rid of the adverts on every page by just adding it to the querystring...
    Posting guidelines I use to see if I will spend time to answer your question : http://www.catb.org/~esr/faqs/smart-questions.html

  • #7
    New Coder
    Join Date
    Jun 2003
    Location
    Massachusetts
    Posts
    24
    Thanks
    0
    Thanked 0 Times in 0 Posts
    PHP Code:
    <?php
    if(!strpos($_SERVER["REQUEST_URI"], "profile.php?mode=register")){
    //show ads
    }
    ?>
    -Matt

  • #8
    New Coder
    Join Date
    Jan 2004
    Location
    Illinois
    Posts
    72
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Thanks Matt... That worked fine

    We miss you @ phpbb-host.org


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •