View Full Version : php: give access to half of my site to correct id/pass ?
10-30-2007, 01:19 PM
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 ?
10-30-2007, 01:56 PM
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.
10-30-2007, 02:33 PM
"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 ?
10-30-2007, 06:29 PM
php.net: Sessions (http://www.php.net/manual/en/ref.session.php)
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).
Powered by vBulletin® Version 4.2.2 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.