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
    New to the CF scene
    Join Date
    Feb 2012
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Giving users own directory

    Im not sure if this is done with PHP, but im guessing it could be.
    Basically what I want is users to rather have or make it appear as they have their own directory.
    Basically instead of heaving a URL as:
    www.mywebsite.com/users.php?user=username

    I want it to be:
    www.mywebsite.com/username

    How do I do this?
    Would I have to make some code which creates a new folder for each new user that registers with a file within that.
    Or is there a way around it in the code without having to create 1000s of new folders for the 1000s of users signing up.

    Thanks
    Ben

  • #2
    Regular Coder Arcticwarrio's Avatar
    Join Date
    May 2012
    Location
    UK
    Posts
    721
    Thanks
    20
    Thanked 84 Times in 84 Posts
    PHP Code:
    <?php
    mkdir
    ("/path/to/my/dir"0700);
    ?>

  • #3
    New to the CF scene
    Join Date
    Jul 2012
    Location
    London
    Posts
    6
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Or you could use a .htaccess file and have a rule that rewites the url so it appears as if they have their own directory, but instead it is returning ?user=username.

  • #4
    Senior Coder
    Join Date
    Sep 2010
    Posts
    1,978
    Thanks
    15
    Thanked 230 Times in 230 Posts
    Make a 'big' directory, separate from all the other directories and files, to keep the user directories in. This will 'sandbox' them from the rest of the site. You can keep all the data in the database and all the user files in a user directory. The user can make subdirectories in the user directory. You can put some files in the user directory, mainly as a backup to the database, but if you have photo albums you might put album pages in it.
    PHP Code:
    $usr_dir "./User_Files/".$user_name;
    $usr_path "./User_Files/".$user_name."/";
    mkdir($usr_dir);
    chmod($usr_dir,0777); 
    It's important that everything be chmodded so that it can be deleted later if need be. In php you have to supply the full path to copy, chmod or move files


  •  

    Posting Permissions

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