nouse4one Posted August 6, 2010 Share Posted August 6, 2010 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? Quote Link to comment Share on other sites More sharing options...
xangelo Posted August 6, 2010 Share Posted August 6, 2010 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. Quote Link to comment Share on other sites More sharing options...
nouse4one Posted August 6, 2010 Author Share Posted August 6, 2010 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? Quote Link to comment Share on other sites More sharing options...
xangelo Posted August 6, 2010 Share Posted August 6, 2010 The code wouldn't really help you too much without a long winded explanation, but this website explains it all very well and also provides you code examples. http://www.desiquintans.com/cleanurls You would still need to store the profile information in a database of some kind to make best use of it. Quote Link to comment Share on other sites More sharing options...
nouse4one Posted August 7, 2010 Author Share Posted August 7, 2010 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] Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.