User registration question

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
nouse4one2
Forum Newbie
Posts: 1
Joined: Fri Aug 06, 2010 3:16 pm

User registration question

Post 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?
User avatar
greyhoundcode
Forum Regular
Posts: 613
Joined: Mon Feb 11, 2008 4:22 am

Re: User registration question

Post 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.
Post Reply