I am using 4 promotional pages (all on different domains) for a service I sell on another domain.
All 5 pages/sites is using "plain" PHP and HTML, no wordpress or other CMS.
So on my sales site I have a login form (written in js) that I want only to be showed if the referer is from my other 4 promotional pages (domains).
So what I need help with is a sctipt that do the following:
People coming from PRdomain1.com, PRdomain2.com, PRdomain3.com and PRdomain4.com will see:
HEADER
CONTENT
LOGIN FORM
FOOTER
and if url to my salesite is typed in directly into addressfield OR come from other domain than my 4 PRdomains they will see:
HEADER
CONTENT
FOOTER
1) Preferably, well crucial than ;-) , it should be compatible with most common browsers. It must be secure (the LOGIN FORM part) in the sense that it should not be retrievable in other way than from the PRdomains as referer.
2) IT MUST WORK, SHOULD NOT MATTER if the PRdomains uses http/https or if the subpage is different, example, PRdomain1.com/landing_page2.php
3) It should not take lot of load? My PRdomain's, all of them, generates massive amounts of traffic to the sales page.
You can do it using jQuery at your page, like this:
HEADER
CONTENT
<div id="#login" style="display: none">LOGIN FORM</div>
FOOTER
<script type="text/javascript">
$(document).ready (
{
if ( document.location.hostname == 'prdomain1.com' || document.location.hostname == 'prdomain2.com' || document.location.hostname == 'prdomain3.com' || document.location.hostname == 'prdomain4.com')
{
$('#login').css ( 'display', 'block');
}
});
</script>
With this code, your LOGIN FORM will be hidden by default because of style="display: none" CSS at <div> tag, and if the current page hostname (accessed by document.location.hostname) has what you're looking for, the script change the display CSS attribute to show the div content.
This might be a solution, but I'm not an expert in this so perhaps someone else herecan confirm??
<?php
$referrer = $_SERVER['HTTP_REFERER'];
if (preg_match("/prdomain1.com/",$referrer)) {
echo 'ALL CONTENT INCL. LOGIN FORM HERE');
} elseif (preg_match("/prdomain2.com/",$referrer)) {
echo 'ALL CONTENT INCL. LOGIN FORM HERE');
} elseif (preg_match("/prdomain3.com/",$referrer)) {
echo 'ALL CONTENT INCL. LOGIN FORM HERE');
} elseif (preg_match("/prdomain4.com/",$referrer)) {
echo 'ALL CONTENT INCL. LOGIN FORM HERE');
} else {
echo 'ALL CONTENT WITHOUT LOGIN FORM HERE');
};
?>