Account with php.

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

I am beginner in PHP. I have already understood the general features
of working with PHP. However, what I cannot make yet is to organise
user's file access with PHP. In more detail users should be identified
by user name and password and then different users have to receive
differen permission to existing HTML files. Do you know how one can
make it?

Thank you.

Re: Account with php. (Q) wrote:

Quoted text here. Click to load it

You're describing a 'shared environment' which relies on the underlaying
OS' permissions scheme (Windows or UNIX) to restrict access to different
user's files.  However, one major limitation of php in this
configuration is that all files must be readable by the web server
running on the machine, so you can only protect files from being written
and deleted, not read.

Read up on your OS' documentation on file permissions.

DeeDee, don't press that button!  DeeDee!  NO!  Dee...

Re: Account with php.

Q wrote:
Quoted text here. Click to load it

You need to first have the user Id and passwords stored in some database.
Preferably with the password encryted.  Most use MySQL for this purpose.  Build
some login form that gathers the information. When the form is submited have
what ever document called by the action method query to validate the input. If
the correct combination is there use:

$_SESSION['username'] = $username;

Every page you want to control access to then needs this code at the beginning
   if(!isset($_SESSION['username'])){//No Session        
      header("Location: login.php");
   }//No Session

Then Check the value in $_SESSION['username'] to see if authorized.

Site Timeline