doubleplusgood
doubleplusgood

Reputation: 2556

Hide content based on URL string (PHP)

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

Upvotes: 2

Views: 715

Answers (3)

Sarfraz
Sarfraz

Reputation: 382666

Try something like:

if (isset($_GET['affiliate']))
{
  // hide the content now
}

Upvotes: 1

Martin Bean
Martin Bean

Reputation: 39389

<?php
if (isset($_GET['affiliate'])) {
    // don't show
}
else {
    // show telephone number
}
?>

Upvotes: 1

Artefacto
Artefacto

Reputation: 97805

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

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

Upvotes: 6

Related Questions