Jump to content

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/154766-solved-simple-php-question-need-help/
Share on other sites

Depends...

 

If ti is not going to be there at all:

 

<?php if(isset($_GET['KeyWord'])) { echo $_GET['KeyWord']; } else { echo "Default Text"; } ?>

 

Or if it is going to be there but be blank

 

<?php if($_GET['KeyWord'] != "") { echo $_GET['KeyWord']; } else { echo "Default Text"; } ?>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.