Help me building a simple php code !!

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
seekndestroy88
Forum Newbie
Posts: 2
Joined: Sun Sep 27, 2009 3:07 pm

Help me building a simple php code !!

Post 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
User avatar
jazz090
Forum Contributor
Posts: 176
Joined: Sun Apr 12, 2009 3:29 pm
Location: England

Re: Help me building a simple php code !!

Post 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
}
?>
seekndestroy88
Forum Newbie
Posts: 2
Joined: Sun Sep 27, 2009 3:07 pm

Re: Help me building a simple php code !!

Post 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
User avatar
jackpf
DevNet Resident
Posts: 2119
Joined: Sun Feb 15, 2009 7:22 pm
Location: Ipswich, UK

Re: Help me building a simple php code !!

Post by jackpf »

This can be easily spoofed btw.
Post Reply