Jump to content

Help with user registration


nouse4one

Recommended Posts

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?

Link to comment
Share on other sites

There is a better way to go about it than what you are describing, but I'll answer your question first and then post what I think.

 

First you'll need a database to store the user information. The username, a unique user_id, password etc.

Whenever a user registers, you'll have to do a lookup to see if the username already exists. If it doesn't, then we can insert the new information into the database and then do the following.

mkdir() will create the directory

fopen() + fwrite() to create the index.html

 

http://www.tizag.com/phpT/filewrite.php

http://ca3.php.net/manual/en/function.fopen.php

http://ca3.php.net/manual/en/function.mkdir.php

http://ca2.php.net/manual/en/function.fwrite.php

 

------

How I would do it is slightly different. Unless I'm letting users store files on my website (and even then... I'd rather centralize that) I would rather give them virtual directories. Meaning, if they go to www.mydomain.com/username it will show their user profile. This is more commonly done through the use of .htaccess files that parse something like www.mydomain.com?q=username to www.mydomain.com/username. If you are interested in this method, please say something, otherwise the method posted above will work.

Link to comment
Share on other sites

Yes i am interested in the other method you suggest. I only want the user created directory to house 1 page thats is it. On this page it will have all the information they entered, reflected from my database. please tell me more about this .htaccess you speak of, would it make this task simpler? and could you show me a code example?

Link to comment
Share on other sites

Yes this was the answer i was seeking! Thank you! It turned out to be much simpler then expected only a few lines of coding solved my problem (2 lines to be exact).

 

The problem: want each user to have a specific url for there profile.

        Example: instead of http://www.mydomain.com/mismatc/viewprofile.php?user_id=12

                      This is what can be used: http://www.mydomain.com/mismatch/12

 

Here is how i did it. Opening up note pad and puting the following code (see attached gif) then saving it as .htaccess, and uploading in into my main host directory.

 

Here are a couple of sites that have some great material on this,wettone.com/code/clean-urls      or    www.desiquintans.com/cleanurls

 

 

 

[attachment deleted by admin]

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.