Page 1 of 1

Help me building a simple php code !!

Posted: Sun Sep 27, 2009 3:14 pm
by seekndestroy88
Consider a domain

"a.com" & "b.com"

from "a.com" i place a link of "b.com" which opens in a new window, now when "b.com" opens there should be a php session start , and during that session when user refresh the page of "b.com" the page should be redirected to "b.com/sample" (i-e i don't want the direct access to "b.com" , i want the access to "b.com" only when it is referred from "a.com")

Can anyone help ?

I am very new to php , so please don't make fun of my Question

Re: Help me building a simple php code !!

Posted: Sun Sep 27, 2009 5:30 pm
by jazz090
use $_SERVER['HTTP_REFERER'] on site b:

Code: Select all

<?php
if ($_SERVER['HTTP_REFERER'] == "sitea"){
    // actions to be executed when users access site b from site a
}
?>

Re: Help me building a simple php code !!

Posted: Mon Sep 28, 2009 3:43 am
by seekndestroy88
Thankyou , and what will be the code for the condition

if site b is not referred by site a then the url should be redirected to siteb/sample.htm

Re: Help me building a simple php code !!

Posted: Mon Sep 28, 2009 7:31 am
by jackpf
This can be easily spoofed btw.