Help me building a simple php code

Discussion in 'PHP' started by seekndestroy88, Sep 27, 2009.

  1. #1
    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
     
    seekndestroy88, Sep 27, 2009 IP
  2. almondj

    almondj Peon

    Messages:
    768
    Likes Received:
    11
    Best Answers:
    1
    Trophy Points:
    0
    #2
    It's not the full code, but this can help in redirecting.

    
    <?php
    
    $url = "http://url.com";
    
    $url = explode(".", $url);
    
    $fixed = $url[0];
    $fixed = "YOURNEWURL";
    echo "<a href=\"$fixed$url\">$fixed$url</a>";
    ?>
    
    PHP:
     
    almondj, Sep 27, 2009 IP
  3. mukunthan

    mukunthan Active Member

    Messages:
    237
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    53
    #3
    <?php
    if ( $_SERVER['HTTP_REFERER'] == "http://www.a.com" )
    header( 'Location: http://www.b.com/sample' ) ;
    else
    echo "Some Error Found";
    echo '<br>You are reffered from '.$_SERVER['HTTP_REFERER'] ;
    ?>

    Try to print $_SERVER['HTTP_REFERER'] and check .. Because i didnt check this
     
    mukunthan, Sep 29, 2009 IP