Page 1 of 1

User registration question

Posted: Fri Aug 06, 2010 3:18 pm
by nouse4one2
New to php and starting to feel way in over my head. Please help, point me in the right direction here. How do i create a new folder with a index.html like (www.mydomain.com/NEWUSER/index.html) when a user registers for my site and have it do live check for AVAILABILITY?

I want to give my users a unique url for there profile. how then do i automate the creation of x.com/newuser/index.html and write it with the users input from my database at the same time?

Re: User registration question

Posted: Fri Aug 06, 2010 4:32 pm
by greyhoundcode

Code: Select all

// Testing if the directory exists
if (file_exists($dirPath))
{
    // Already taken
    echo 'Please choose a different name...';
}
else
{
    // Available
    if (mkdir($dirPath))
        echo 'New directory created';
    else
        echo 'Unable to create the directory';
}
Something like the above perhaps (not tested by the way). You would need to substitute some code to build the profile page.

An alternative approach that might interest you would be that, instead of creating physical directories on the filesystem, you make use of URL rewriting and keep it all in the database. All you would then need is a single view file or template for the profile page.