php - Add multiple referrer links -
i protect page being access , can access referrer page, here code on landing page
<?php // request file coming test referrer if(stristr($_server['http_referer'],"http://aqsv.com/sites2/testreffer/tp1.php")) { ?> <!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title>untitled document</title> </head> <body> <h1>test landing page 1</h1> </body> </html> <?php } // redirect redirect.php else { header("location: http://aqsv.com/sites2/testlander/redirect.php"); } ?> and referrer page
<html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" /> <title>test refererrer 1</title> </head> <body> <h1>test refererrer 2</h1> <a href="http://aqsv.com/sites2/testlander/lp1.php">link me landing page1</a> </body> </html> this work on single referrer page only, want have multiple referrer page access page , im new php , dont have idea this.. tried adding http referrer using if else
<?php // request file coming test referrer if(stristr($_server['http_referer'],"http://aqsv.com/sites2/testreffer/tp1.php")); elseif(stristr($_server['http_referer'],"http://aqsv.com/sites2/testreffer/tp2.php")) { ?> but second link not working. highly appreciated.
you can take array containing valid referrer domain. e.g.
<?php $valid_domains = array( 'domain1', 'domain2', 'domain3' ); // checking valid domain if ( in_array($_server['http_referer'], $valid_domains) ) { ?> html goes here.... <?php } ?> please see http://php.net/manual/en/function.in-array.php
hope idea you.
Comments
Post a Comment