Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New to the CF scene
    Join Date
    May 2014
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    No direct linking code?

    Hello,

    Im a newbie in php. I need a code to not allow users to go directly to a link. Im not talking about hotlink protection through my cpanel. But what I want to have is: users have to go to a "first page", before they can access the "actual page". For example, the link I want to protect is: link.php. I want it so that they always have to pass through pass.php before they can go to link.php. When they go directly to link.php (by either entering the url or clicking a link of that page on another site), they would be redirected to pass.php. How can I do this?

    I know there's a code for this that I have used before. It's like the php code checks the browsers url in order to do this... But I forgot how to do it.

    Please help.

  • #2
    Senior Coder
    Join Date
    Jan 2011
    Location
    Missouri
    Posts
    4,105
    Thanks
    23
    Thanked 594 Times in 593 Posts
    Link to pass.php
    pass.php has only this:
    header("Location: http://mydomain.com/link.php");
    die();

    Done it's called redirection.
    Evolution - The non-random survival of random variants.

    "If you leave hydrogen alone, for long enough, it begins to think about itself."

  • #3
    New to the CF scene
    Join Date
    May 2014
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by sunfighter View Post
    Link to pass.php
    pass.php has only this:
    header("Location: http://mydomain.com/link.php");
    die();

    Done it's called redirection.
    That's not what I mean. Pass.php will also have an entire content of a page. I'm thinking maybe it's not php, but javascript or something.

  • #4
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,852
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    Use sessions - set a session variable in pass.php and check for its existence in link.php
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #5
    Regular Coder
    Join Date
    Sep 2011
    Posts
    410
    Thanks
    18
    Thanked 26 Times in 26 Posts
    Quote Originally Posted by abduraooft View Post
    Use sessions - set a session variable in pass.php and check for its existence in link.php
    On top of that, if you don't want to allow refreshes you can destroy the variable right after you check for it to cause it to fail on refresh.
    If I've helped you out, show your appreciation by clicking the "Thanks" link as well as a link below!

    AdFly
    Facebook | Twitter
    Google | YouTube

  • #6
    Senior Coder
    Join Date
    Jan 2011
    Location
    Missouri
    Posts
    4,105
    Thanks
    23
    Thanked 594 Times in 593 Posts
    If you don't use a reset in the php file you are going to show the user the address one way or the other. You do know that you can use a timer on the redirect:
    header( "refresh:5; url = http://mydomain.com/link.php" );
    That way you can generate the page and allow it to show for a length of time before it moves on.
    Evolution - The non-random survival of random variants.

    "If you leave hydrogen alone, for long enough, it begins to think about itself."


  •  

    Posting Permissions

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