Smackie Posted June 11, 2008 Share Posted June 11, 2008 Greetings, I'm alittle new to mkdir lol.. here is what im wanting to do. When a user signs up for my site (after the fill in the fields and press submit) it will send them to a new page. which will send there data to database. how can i make it where it will create a new sub folder in say users sub folder..? Sorry if i confused ya there. basically when a user signs up it will create a sub folder (named Smackie) it will put it in users so say it would be www/users/Smackie or however the path is.. how can i do this? Thank you Smackie Quote Link to comment Share on other sites More sharing options...
craygo Posted June 11, 2008 Share Posted June 11, 2008 one of the biggest problem with mkdir() is permissions. Make sure you have at least 775 rights to the users folder that way you can create folders in it. Quote Link to comment Share on other sites More sharing options...
Smackie Posted June 11, 2008 Author Share Posted June 11, 2008 well right now im using Xampp so i don't need to worry about permissions lol but yeah i know about permissions to do that but see im not sure on how i would do the mkdir() using my register script.. Quote Link to comment Share on other sites More sharing options...
xtopolis Posted June 12, 2008 Share Posted June 12, 2008 <?php $create_folder = 'someusername'; //this is the name of the folder you want to create $dir = '../'; //define your USERS directory, relative to the script that is running's location if(!$dh = opendir($dir)) { echo('Failed to open directory: ' . $dir . ); }//open dir //read folders/(i think this would pick up files as well)that already exist from the directory //place into an array to search $fileList = array(); while (false !== ($file = readdir($dh))) { if ($file != "." && $file != "..") { $fileList[] = $file; } }//while closedir($dh); //check that there are no matching folder names if(in_array($create_folder,$fileList)) { echo('Directory ' . $create_folder . ' already exists.'); }else{ // REMEMBER TO have MKDIR's path relative to the scripts location or else it will make it in the same folder as the running script! if(!mkdir("../$create_folder", 0700)) { echo('Failed to create directory.'); } ?> Quote Link to comment Share on other sites More sharing options...
GingerRobot Posted June 12, 2008 Share Posted June 12, 2008 It's more than likely you would be better off using some re-writing rules to make it appear that a user has a folder. 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.