Discover Habbo's history
Treat yourself with a Secret Santa gift.... of a random Wiki page for you to start exploring Habbo's history!
Happy holidays!
Celebrate with us at Habbox on the hotel, on our Forum and right here!
Join Habbox!
One of us! One of us! Click here to see the roles you could take as part of the Habbox community!


Results 1 to 7 of 7
  1. #1
    Join Date
    Nov 2007
    Location
    London
    Posts
    1,577
    Tokens
    36

    Latest Awards:

    Default Simple PHP Help +rep

    Hello,

    Basically, I need to make a script that shows certain code "if" you have "HTTP_REFERER" of index.php, but "else" you get redirected to index.php. I need it to work in as many internet browsers as possible but just internet explorer is fine.

    I have had a go at it myself but can't seem to actually get it working.

    Here are snippets of code:

    index.inc.php:

    Code:
    <?
    
    $_httpreferer = $_SERVER['HTTP_REFERER'];
    if ($_httpreferer == "index.php") {
    
    ?>
    At the end of the content on index.inc.php....

    Code:
    <?php
    }
    else  {
    header("Location: index.php");
    }
    ?>
    Errors:

    Notice: Undefined index: HTTP_REFERER in /home/youngmus/public_html/browse/index.inc.php on line 3

    Notice: Undefined variable: _httpreferer in /home/youngmus/public_html/browse/index.inc.php on line 3

    Notice: Undefined variable: _httpreferer in /home/youngmus/public_html/browse/index.inc.php on line 4

    Warning: Cannot modify header information - headers already sent by (output started at /home/youngmus/public_html/browse/index.inc.php:3) in /home/youngmus/public_html/browse/index.inc.php on line 126
    Any ideas on how to get it to work?
    Last edited by iUnknown; 27-02-2008 at 06:30 PM.
    Kind Regards,

    Guy
    __________________

    Since 2007. Unbelievable Uptime. Web hosting, resellers, master resellers, linux VPS, windows VPS, shoutcasts, at the lowest prices on the net.
    Tech-Hosts.co.uk.


  2. #2
    Join Date
    May 2006
    Posts
    1,797
    Tokens
    0

    Latest Awards:

    Default

    Try..

    PHP Code:
    <?php
    $ref 
    $_SERVER['HTTP_REFERER']
    if(
    eregi("index.php",$ref))
    {
    /*
    Referrer is index.php
    */
    }
    else
    {
    echo(
    '<meta http-equiv="refresh" content="0;url=index.php" />');
    }
    ?>
    Last edited by MrCraig; 27-02-2008 at 06:48 PM.
    Coming and going...
    Highers are getting the better of me

  3. #3
    Join Date
    Dec 2007
    Posts
    174
    Tokens
    100

    Default

    If all else fails, you could try setting a session when they visit the index page, and if that session is not set then redirect them to the index page.

    Good luck.
    Best regards,

    Scott Graham
    “When you have confidence, you can have a lot of fun. And when you have fun, you can do amazing things.”

  4. #4
    Join Date
    May 2006
    Posts
    1,797
    Tokens
    0

    Latest Awards:

    Default

    Sorry, spotted error.

    PHP Code:
     
    <?php
    $ref 
    $_SERVER['HTTP_REFERER'];
    if(
    eregi("index.php",$ref))
    {
    /*
    Referrer is index.php
    */
    }
    else
    {
    echo(
    '<meta http-equiv="refresh" content="0;url=index.php" />');
    }
    ?>
    Coming and going...
    Highers are getting the better of me

  5. #5
    Join Date
    Nov 2007
    Location
    London
    Posts
    1,577
    Tokens
    36

    Latest Awards:

    Default

    Still not working, but less errors:


    Notice: Undefined index: HTTP_REFERER in /home/youngmus/public_html/browse/index.inc.php on line 3

    Plus, it redirects to index.php.
    Kind Regards,

    Guy
    __________________

    Since 2007. Unbelievable Uptime. Web hosting, resellers, master resellers, linux VPS, windows VPS, shoutcasts, at the lowest prices on the net.
    Tech-Hosts.co.uk.


  6. #6
    Join Date
    May 2006
    Posts
    1,797
    Tokens
    0

    Latest Awards:

    Default

    By Sessions..

    On your index.php page put at the very top of code:
    PHP Code:
    <?php
    session_start
    ();
    $_SESSION["ads"] = 1;
    ?>
    Then in your redirect page, put in, at very top again
    PHP Code:
    <?php
    session_start
    ();
    if(!isset(
    $_SESSION["ads"]))
    die(
    '<meta http-equiv="refresh" content="0;url=index.php" />');
    ?>
    Coming and going...
    Highers are getting the better of me

  7. #7
    Join Date
    Nov 2007
    Location
    London
    Posts
    1,577
    Tokens
    36

    Latest Awards:

    Default

    Hooray it works perfectly - and amazingly! Just what I wanted, very pleased thank you.

    +rep and a special gift that I didn't say at the beginning just because you always help me
    Kind Regards,

    Guy
    __________________

    Since 2007. Unbelievable Uptime. Web hosting, resellers, master resellers, linux VPS, windows VPS, shoutcasts, at the lowest prices on the net.
    Tech-Hosts.co.uk.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •