Welcome to Welcome to DNF.com™ - Domain Sales, Domain Forum, Domain Appraisals, Domain Registrars

If you are new to domains and looking to buy, sell and learn about domains then you have come to the right place. DNForum is the largest domain name community on the internet and continues to grow every day. There are over 105,000 domainers on DNForum doing everything from buying domains, selling domains, learning about domains and discussing domains. Take a minute and Register.

Register Today on DNForum IT'S FREE!

Results 1 to 9 of 9
  1. #1
    Selling
    BLazeD's Avatar
    Join Date
    Apr 2004
    Location
    New Zealand
    Posts
    3,055
    DNF$
    33
    Bank
    12,403
    Total DNF$
    12,436
    Donate  

    Arrow Real Easy PHP/Java Query

    I have a site, eg www.house.com

    I want one ad to show on every single page, except any page that has www.house.com/forum* in the URL.

    For the pages that have www.house.com/forum* in the URL I want to show another ad.

    I guess either javascript or PHP could do this.

    eg.

    Define URL

    IF URL=www.house.com/forum*

    Then

    Display AD2

    ELSE

    Display AD1

    I know how it should work, just not the actual code.

    Help much appreciated!!!!

    PS: Any questions about what I have said please ask, I really need this help

  2. #2
    www.LOL.biz
    Bender's Avatar
    Join Date
    Apr 2004
    Location
    .ro
    Posts
    1,912
    DNF$
    6,243
    Bank
    0
    Total DNF$
    6,243
    Donate  

    Re: Real Easy PHP/Java Query

    Code:
    <script type="text/javascript">
    //****************configuration **********************//
    //string to look for 
    lookFor="www.house.com/forum";
    
    //HTML to display when the string was NOT found -take care of the proper quotes embedding-
    // do not add single quotes without addin a \ first
    HTML1='<img src="http://www.mysolarsystem.com/images/jupiter.jpg">';
    
    //HTML to display when the string was  found
    HTML2='<img src="http://www.mysolarsystem.com/images/saturn.jpg">';
    
    //****************configuration ends here  **********************//
    w=location.href;
    
    index=w.indexOf(lookFor);
    if(index=-1){
    //the current URL does not contain searched string
    document.write(HTML1);
    }
    else{
    //the current URL contains the searched string
    document.write(HTML2);
    }
    
    </script>
    I hope this helps.
    PS:
    Java and javascript are extremely different...
    Last edited by IT Web Team; 06-17-2005 at 02:32 AM.

  3. #3
    Selling
    BLazeD's Avatar
    Join Date
    Apr 2004
    Location
    New Zealand
    Posts
    3,055
    DNF$
    33
    Bank
    12,403
    Total DNF$
    12,436
    Donate  

    Re: Real Easy PHP/Java Query

    Cheers man,

    I dont think it is working though, because the ads themselves are java and I dont know how to edit them to be compatible with the above.

    Some other guy suggested

    <? if (eregi('www.house.com/forum', $_SERVER['HTTP_HOST'].'/'.$_SERVER['PHP_SELF'])) { ?>
    Display AD2
    <? } else { ?>
    Display AD1
    <? } ?>

    But it only displays AD1, even when AD2 is meant to be displayed.

  4. #4
    www.LOL.biz
    Bender's Avatar
    Join Date
    Apr 2004
    Location
    .ro
    Posts
    1,912
    DNF$
    6,243
    Bank
    0
    Total DNF$
    6,243
    Donate  

    Re: Real Easy PHP/Java Query

    If you prefer PHP,here is the code.
    The JavaScript(not Java!) method works as well, both tested.

    Code:
    <?
    $lookFor="www.house.com/forum";
    $url = $HTTP_SERVER_VARS["HTTP_HOST"] . $HTTP_SERVER_VARS["REQUEST_URI"];
     if (eregi($lookFor, $url)) { ?> 
    Display AD2 
    <? } else { ?> 
    Display AD1 
    <? } ?>

  5. #5
    Selling
    BLazeD's Avatar
    Join Date
    Apr 2004
    Location
    New Zealand
    Posts
    3,055
    DNF$
    33
    Bank
    12,403
    Total DNF$
    12,436
    Donate  

    Re: Real Easy PHP/Java Query

    Awesome

    I have it going now - thanks a lot!

  6. #6
    DNF Addict
    Mr.Domains's Avatar
    Join Date
    Sep 2004
    Location
    Geneva, Switz.
    Posts
    1,868
    Country

    Great Britain
    DNF$
    3,233
    Bank
    6,090
    Total DNF$
    9,323
    Donate  

    Re: Real Easy PHP/Java Query

    Quote Originally Posted by IT Web Team
    The JavaScript(not Java!) method works as well, both tested.
    Lol, I get this all the time! In fact, last birthday my wife even gave me a great big "Programming Java Applets" manual, and then was quite affronted when I tried to explain to her that I don't use Java and had no interest in learning how too. - "But you did that JavaScript course last summer and said it had been really useful to you?"
    Neil Hillman - Web Developer, Pixel Pusher...

  7. #7
    Selling
    BLazeD's Avatar
    Join Date
    Apr 2004
    Location
    New Zealand
    Posts
    3,055
    DNF$
    33
    Bank
    12,403
    Total DNF$
    12,436
    Donate  

    Re: Real Easy PHP/Java Query

    Any idea how to change the PHP version of this code, to include multiple URLs?

    ie. abc.com/a.php and abc.com/b.php it doesnt display

    But for any other abc.com address it will display?

    Cheers

  8. #8
    Platinum Lifetime Member
    csmaster2005's Avatar
    Join Date
    Jul 2004
    Location
    United States
    Posts
    456
    DNF$
    1,840
    Bank
    0
    Total DNF$
    1,840
    Donate  

    Re: Real Easy PHP/Java Query

    all you'd have to do is change the $lookfor variable.
    basically what the script is doing is just checking what the url that is being requested is, then compares the url against the lookfor variable, and does a simple if else statement.
    easy to modify for any site.
    Tyler Cruz schooled me in BW, so he won this until May 23rd, 2011 TylerCruz

  9. #9
    Platinum Lifetime Member

    Join Date
    Jun 2005
    Posts
    539
    DNF$
    10,653
    Bank
    0
    Total DNF$
    10,653
    Donate  

    Re: Real Easy PHP/Java Query

    can u explain the code pleasE?
    i m a newbie {learning php} and would like to know wt this code means

    <?
    $lookFor="www.house.com/forum";
    $url = $HTTP_SERVER_VARS["HTTP_HOST"] . $HTTP_SERVER_VARS["REQUEST_URI"];
    if (eregi($lookFor, $url)) { ?>
    Display AD2
    <? } else { ?>
    Display AD1
    <? } ?>

Bookmarks

Posting Permissions

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

Domain name forum recommended by Domaining.com