Hello i have a registration form for my site that will take a username, and password and put it into a mysql database. I also want a folder to be made when the click register. How can i do this with php?

    Ok wow that was easy.

    Now how can i make the contents of that directory only viewable by a perticular user.

    For example: ( a person makes an account with the username "smith" and as a result the folder named "smith" is created. how can i be sure only the user "smith" can view that folder?)

    thanks

      That would depend on how they "view" directories in the first place. If you have some sort of PHP interface that lists files in a directory, then you'd simply take the username they logged in with and build the directory path using that.

        i'm not really sure which way i have it now. (i've never done this before)

        right now i have the folders being created into a directory called 'accounts' on the webserver. so what you can do if you know the username of the folder is http://www.domain.com/accounts/smith and the contents of that folder are there.

        What way do you suggest doing this?

          Well what is the purpose of creating these folders for each user? Is it some sort of webspace where they can upload and store files?

            yes thats exactly what its for. Just a folder assoicated with their username so they can store files and images for their account) But only that user and myself will be able to view the files of that directory.

              once the person logs in they will have a link going to that folder to download/upload files.

              the way i listed above would be a potential loop hole though.

                I think the easiest way to do this would be to deny all access to the folders themselves and have a PHP gateway that checks if they've logged in.

                If so, you could use functions such as [man]glob/man to list the contents of their directory for them. The links would point back to the script itself with the filepath in the query string; that way you could use [man]file_get_contents/man to read the file they're after and send it to them (using the appropriate headers).

                  ok how can i deny all access to the folders then?

                  And for your method... i'm not sure exactly how its supposed to be done.

                  glob ( string $pattern [, int $flags] )

                  i'm not sure what paramaters get used for my application. I probally need the no_sort but i'm not really sure. and how will it know to get contents from directory 'accounts/$user'

                    Write a Reply...