Prevent users from typing the url manually

Discussion in 'PHP' started by enchance, Sep 30, 2009.

  1. #1
    I'm a php noob and I wanted to ask if you guys know how to prevent users from typing a URL manually? The page isn't ready yet but it might be site.com/custom.php or something like that. To get to the page they need to type in a password which is relatively easy to do in PHP.

    Advanced thanks to everyone.

    Cheers,
    John
     
    Last edited: Sep 30, 2009
    enchance, Sep 30, 2009 IP
  2. premiumscripts

    premiumscripts Peon

    Messages:
    1,062
    Likes Received:
    48
    Best Answers:
    0
    Trophy Points:
    0
    #2
    If it's password protected you should just start a session after validating that the password is correct.

    session_start();
    $_SESSION['logged_in'] = true;

    Then, on the protected page:

    session_start();
    if (empty($_SESSION['logged_in'])) {
    header('Location: http://site.com/notallowed');
    die();
    }
     
    premiumscripts, Oct 1, 2009 IP