1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Help me with this php "(:(:(

Discussion in 'PHP & Perl' started by jr D.I.P, Jan 8, 2013.

  1. jr D.I.P

    jr D.I.P Power Member

    Joined:
    Jan 31, 2012
    Messages:
    694
    Likes Received:
    377
    Location:
    goo.gl/h3INI
    <?php if ( "M ON THIS IS URL" ) : ?>


    then content here


    <?php endif; ?>


    how to "??
     
  2. Zapdos

    Zapdos Power Member

    Joined:
    Oct 22, 2011
    Messages:
    597
    Likes Received:
    708
    Location:
    Eastern North Carolina
  3. alias_unknown

    alias_unknown Newbie

    Joined:
    Dec 30, 2012
    Messages:
    41
    Likes Received:
    4
    Please can you try to explain the problem further...
     
  4. Kilise

    Kilise Newbie

    Joined:
    Dec 10, 2011
    Messages:
    34
    Likes Received:
    5
    Lets say you are on:
    http://yoursite.com/index.php?page=here

    if($_GET['page'] == 'here'){
    echo "IM HERE";
    }else{
    echo "this will be shown if the page isnt here";
    }
     
  5. firescape

    firescape Newbie

    Joined:
    Feb 1, 2013
    Messages:
    10
    Likes Received:
    0
    You can use query strings, cookies, or other means of tracking state. I recommend you learn how to make an if statement and the basics before learning this.
     
  6. Eightomic

    Eightomic Registered Member Premium Member

    Joined:
    Oct 20, 2012
    Messages:
    60
    Likes Received:
    13
    Occupation:
    Web Developer / Designer
    Location:
    United States
    Home Page:
    Just replace the example URLs with the correct URLs and this will work:

    Code:
    <?php
        $url = 'your full url here';
        $getCurrentUrl = $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
        if (strstr($fullUrl, 'your full url here')):
    ?>
        Place page content here.
    <?php else: ?>
        Other content here.
    <?php endif; ?>
    ?>
    If you just want to use what comes after the domain name, use only $_SERVER['REQUEST_URI'] as shown below:

    Code:
    <?php
        $url = 'your full URL here';
        $afterUrl = $_SERVER['REQUEST_URI'];
        if (strstr($afterUrl, 'your partial url here')):
    ?>
        Place page content here.
    <?php else: ?>
        Other content here.
    <?php endif; ?>
    ?>
     
    Last edited: Feb 24, 2013
  7. nickcarter

    nickcarter Newbie

    Joined:
    Feb 19, 2013
    Messages:
    15
    Likes Received:
    3
    ANY-URL?M=any-variable

    <?php
    if(isset($_GET['M']) && $_GET['M']!=='') :
    ?>

    any content

    <?php endif ?>
     
  8. Gogol

    Gogol Elite Member

    Joined:
    Sep 10, 2010
    Messages:
    3,062
    Likes Received:
    2,872
    Gender:
    Male
    What is so nice about it?
     
  9. Gogol

    Gogol Elite Member

    Joined:
    Sep 10, 2010
    Messages:
    3,062
    Likes Received:
    2,872
    Gender:
    Male
    Are you kidding ?! cookiess for determining the page url?:rocketwho