hello there, can someone tell me how i can make this command <?php $website_referer = $_SERVER['HTTP_REFERER']; if ($website_referer != "http://www.google.com") { echo 'None'; } else { echo 'Google Referer'; } ?> example: http://www.google.com/search.php .... = echo 'Google Referer'; i try http://www.google.com* but is not working ... can someone tell me how i can fix this command thanks
take a look at parse_url() That should be all you need and then just match the host name which should be www.google.com
<?php $website_referer = $_SERVER['HTTP_REFERER']; if (stristr($website_referer,"google.com") { echo 'None'; } else { echo 'Google Referer'; } ?> PHP:
<?php $website_referer = preg_replace('~^www\.~', '', parseurl($_SERVER['HTTP_REFERER'], PHP_URL_HOST)); if ($website_referer != "google.com") { echo 'None'; } else { echo 'Google Referer'; } ?> PHP: