Current location: Hot Scripts Forums » Programming Languages » PHP » how to make dir on new registration?


how to make dir on new registration?

Reply
  #1 (permalink)  
Old 01-06-06, 03:54 PM
recedo recedo is offline
Newbie Coder
 
Join Date: Dec 2004
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
how to make dir on new registration?

I am trying to modify a script I have so when a new user signs up it creates a folder for them.

The script is located at http://www.mysite.com/folder1

I want their folder to be created at http://www.mysite.com/folder2/username

so in relation to the script it would need to be ../folder2/NEWFOLDER (based on their username).

The user does not need to know that this folder has been created or anything, as it is for admin use only.

Any help would be appreciated.

Regards
Simon
Reply With Quote
  #2 (permalink)  
Old 01-06-06, 04:00 PM
Christian's Avatar
Christian Christian is offline
Community VIP
 
Join Date: Mar 2005
Location: ProgrammingTalk
Posts: 2,449
Thanks: 0
Thanked 6 Times in 5 Posts
I think that you have to use mkdir.
Reply With Quote
  #3 (permalink)  
Old 01-06-06, 04:11 PM
recedo recedo is offline
Newbie Coder
 
Join Date: Dec 2004
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Thanks for the link.

So in theory, all I would have to add to make a new folder called "newfolder" is;

PHP Code:

mkdir("../folder2/newfolder"0777); 

Is that correct (I would want the folder to be set as 777).

The next step will be finding out what is used to make the username, add underscores to it if there are any spaces and add that in instead of "newfolder".

Anyone know how to do part 2?

Please bear in mind that I'm a complete noob and I'm not trying to become an expert in php or anything, just trying to do what needs to be done!

Thanks

Last edited by recedo; 01-06-06 at 04:20 PM.
Reply With Quote
  #4 (permalink)  
Old 01-06-06, 04:34 PM
Christian's Avatar
Christian Christian is offline
Community VIP
 
Join Date: Mar 2005
Location: ProgrammingTalk
Posts: 2,449
Thanks: 0
Thanked 6 Times in 5 Posts
With out your complete registration script, I will only be able to guess.
PHP Code:

mkdir("/folder2/".$_POST['username'].""0777); 

Change $_POST['username'] to whatever is telling you script what the folder name is. Yes you want it be 777.
Reply With Quote
  #5 (permalink)  
Old 01-06-06, 07:48 PM
Richard's Avatar
Richard Richard is offline
Wannabe Coder
 
Join Date: Sep 2005
Location: Oxford, UK
Posts: 239
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by recedo
The next step will be finding out what is used to make the username, add underscores to it if there are any spaces and add that in instead of "newfolder".
PHP: str_replace - Manual
PHP Code:

$newUsername str_replace(" ""_"$_POST['username']); 

Reply With Quote
  #6 (permalink)  
Old 01-06-06, 08:27 PM
Christian's Avatar
Christian Christian is offline
Community VIP
 
Join Date: Mar 2005
Location: ProgrammingTalk
Posts: 2,449
Thanks: 0
Thanked 6 Times in 5 Posts
Quote:
Originally Posted by Richard
PHP: str_replace - Manual
PHP Code:

$newUsername str_replace(" ""_"$_POST['username']); 

I didn't catch that, thanks.
this is the new code:
PHP Code:

$newUsername str_replace(" ""_"$_POST['username']);

mkdir("/folder2/".$newUsername.""0777); 
Reply With Quote
  #7 (permalink)  
Old 01-06-06, 09:34 PM
recedo recedo is offline
Newbie Coder
 
Join Date: Dec 2004
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Thanks guys, I appreciate the help.

I have not even looked at the code myself yet so I'm not sure what the username variable would be called, but I'm sure I can figure that out.

Can you think of any issues that may be caused with this script? For example anything that may cause that code to fail and cause an error.

The script will not be ran by members of the public, only our staff, as we create the accounts 'manually' for our members.

Also, just looking at the code again, you put "/folder2/". Would I not need to use "../folder2/" as folder2 is on the same level as folder1 eg;

http://www.site.com/folder1
http://www.site.com/folder2
http://www.site.com/folder2/username
http://www.site.com/folder2/username2
etc

Also, would it be best to add this code to the end of the rest or at the beginning? I would guess the end.

Thanks again (and thanks for the links to the manual too)
Simon

Last edited by recedo; 01-06-06 at 09:37 PM. Reason: additional question
Reply With Quote
  #8 (permalink)  
Old 01-06-06, 09:49 PM
Christian's Avatar
Christian Christian is offline
Community VIP
 
Join Date: Mar 2005
Location: ProgrammingTalk
Posts: 2,449
Thanks: 0
Thanked 6 Times in 5 Posts
Quote:
Originally Posted by recedo
Also, just looking at the code again, you put "/folder2/". Would I not need to use "../folder2/" as folder2 is on the same level as folder1 eg;
I think that the code should work, you should try it.
Quote:
Originally Posted by recedo
Also, would it be best to add this code to the end of the rest or at the beginning? I would guess the end.
Do you mean at the end of the registration script? If yes, then you schould place it where you add the infomation to your database(if you using one).
__________________
:: ImperialBB :: New version in the works! :: http://www.imperialbb.com ::

:: Have a question about the board? The Rules? An Infraction/Warning? :: Contact Form ::
Reply With Quote
  #9 (permalink)  
Old 01-06-06, 09:54 PM
recedo recedo is offline
Newbie Coder
 
Join Date: Dec 2004
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by dead-poetic
Do you mean at the end of the registration script? If yes, then you schould place it where you add the infomation to your database(if you using one).
Yes, thats what I mean, so it should be at the end of the code that adds the details to the database.

I will try this out when I get the time, hopefully tomorrow morning.

Thanks again
Simon
Reply With Quote
  #10 (permalink)  
Old 01-06-06, 09:59 PM
Christian's Avatar
Christian Christian is offline
Community VIP
 
Join Date: Mar 2005
Location: ProgrammingTalk
Posts: 2,449
Thanks: 0
Thanked 6 Times in 5 Posts
Quote:
Originally Posted by recedo
Yes, thats what I mean, so it should be at the end of the code that adds the details to the database.
Yes, thats what I would do. Your Welcome.
__________________
:: ImperialBB :: New version in the works! :: http://www.imperialbb.com ::

:: Have a question about the board? The Rules? An Infraction/Warning? :: Contact Form ::
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
how to make .htacess to include html in all the dir aemobile PHP 2 04-27-05 01:10 PM


All times are GMT -5. The time now is 06:27 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.