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

*Need help with this php problem!*

Discussion in 'PHP & Perl' started by DimaKritchevski, Apr 19, 2009.

  1. DimaKritchevski

    DimaKritchevski Registered Member

    Joined:
    Jan 29, 2009
    Messages:
    61
    Likes Received:
    126
    Occupation:
    Master of Extended Unemployment
    Location:
    Melb, AUS
    Home Page:
    Hey there,

    This is a simple problem with php code that I'm sure anyone with a decent knowledge of php can fix.... Here's what's going on:

    I'm sending adwords traffic to a website with the following piece of code added on to the end of the destination url:

    http://url.com/?KeyWord=Product Name

    I'm then inserting the snippet as follows to add the KeyWord into my H1 tag

    <H1><?php echo $_GET['KeyWord']; ?></H1>

    The question is... how do I add a parameter to specify that if the KeyWord variable is blank to insert "Default Text" rather than just leaving KeyWord blank.

    ---------------------------------------------------------------------------

    Just to be abundantly clear

    Destination URL: http://url.com/?KeyWord=Weight Watchers

    Headline: <?php echo $_GET['KeyWord']; ?>

    I want it to be more like...

    Headline: "KeyWord" and if KeyWord is blank to default to "Lite N Easy".

    I'm sure this is an easy problem to fix for anyone who knows their stuff.

    Thanks in advance!

    - Dima
     
  2. thaorius

    thaorius Junior Member

    Joined:
    Aug 19, 2008
    Messages:
    109
    Likes Received:
    33
    Headline: <?php echo isset($_GET['KeyWord']) ? $_GET['KeyWord']: 'Lite N Easy'; ?>

    Enjoy.
     
  3. aReJay

    aReJay Power Member

    Joined:
    Apr 29, 2009
    Messages:
    736
    Likes Received:
    237
    Location:
    Down under
    <?
    if(isset($_GET['KeyWord'])){
    echo $_GET['KeyWord'];
    }else{
    echo "Insert Default Text Here"; // Replace text, leaving quotes
    }
    ?>