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 4 of 4
  1. #1
    Regular Coder
    Join Date
    Dec 2005
    Posts
    702
    Thanks
    0
    Thanked 0 Times in 0 Posts

    php: give access to half of my site to correct id/pass ?

    What method to use in PHP to give access to half of my site to all visitors but the other half only to those with appropriate id/password ?

  • #2
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,539
    Thanks
    8
    Thanked 1,093 Times in 1,084 Posts
    When you mean half, do you mean there are pages mixed together,
    some they can access, some they can't?

    With PHP, you would use sessions. Creating a log-in part. If there are only
    a couple that use the "protected" part, the log-in would be simple, otherwise,
    for many members, you would need to use a database to store member
    information, registration, etc.

    At the top of each protected page, the PHP script would check for the
    logged-in user and display only if logged-in.

    See Google for: PHP sessions

    See Google for information on parsing your HTML pages as PHP without
    changing the extensions of your files.

  • #3
    Regular Coder
    Join Date
    Dec 2005
    Posts
    702
    Thanks
    0
    Thanked 0 Times in 0 Posts
    "At the top of each protected page, the PHP script would check for the
    logged-in user and display only if logged-in." the session will do that ? can give a sample ? If a visitor type the whole URL session will deny access to him and appear login dialog box page ?

  • #4
    Senior Coder
    Join Date
    Jan 2007
    Posts
    1,648
    Thanks
    1
    Thanked 58 Times in 54 Posts
    No.

    php.net: Sessions

    You will have to make your own login page, your own validation code, and you will have to manually check on each of the specific pages to see whether they are logged in.

    The only 'automatic' login available is through .htaccess, which would be silly to set up for specific pages (it's not impossible).


  •  

    Posting Permissions

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