tags:

views:

57

answers:

3

Hi there,

I've signed up to one of those affiliate sites to help drive traffic to my online store. They've asked that I hide the telephone number on my site for referring traffic.

All traffic that they refer will append any of my site urls with something like '?affiliate'.

Does anyone know how I can hide content on a page if a URL contains '?affiliate' but show it if the URL does not contain this text?

I'm using the Magento system, in case that makes a difference. :D

Thanks, Neil

+5  A: 
if (!array_key_exists('affiliate', $_GET)) {
    //show telephone number
}

empty will fail here because the value of $_GET['affiliate'] will be "".

Artefacto
Hey, I've tried using this as follows. But it always shows the number. I need it to show the number by default, unless the url contains affiliate.if (!array_key_exists('affiliate', $_GET)) { echo "<p>020 XXXXXX</p>";}
Neil Bradley
Artefacto
+1  A: 
<?php
if (isset($_GET['affiliate'])) {
    // don't show
}
else {
    // show telephone number
}
?>
Martin Bean
+1  A: 

Try something like:

if (isset($_GET['affiliate']))
{
  // hide the content now
}
Sarfraz
I think this will fail: The manual on isset() says *"Determine if a variable is set and is not NULL."* `affiliate` will be null in this case.
Pekka
@Pekka I was actually wrong there. It will be `""`. This is also correct.
Artefacto
@Artefacto you're right, `isset()` indeed works. I stand corrected!
Pekka
@Pekka I actually was induced in error with a phpinfo page, which showed "no value", which I assumed mean NULL.
Artefacto