Author Topic: Hello quick question about mkdir  (Read 302 times)

RobPuck

  • New Member
  • *
  • Posts: 6
  • Karma: +0/-0
    • View Profile
Hello quick question about mkdir
« on: September 03, 2010, 08:28:43 PM »
So heres what I would like to try to do.
When some one registers on my site i want to give them a personal folder where i can pull data back to the client with a var in flash.
 
So it sould work like this
on my host default folder for all users would be user.
then
user/username/
example
user/RobPuck/
user/Mancent/
 
PHP Code: [Select]
 
<?php
$username 
$_POST['username'];
$path "users/".$username."/";
//TO DO Add a way where if username is in use fail.
if( USERNAME IS OPEN DO IT)
{
mkdir($path0755);
echo 
"It Worked"
}
else
{
echo 
"It Failed";

 
?>

phphelp

  • Administrator
  • Senior Member
  • *****
  • Posts: 777
  • Karma: +3/-0
    • View Profile
    • PHP Help forum
Re: Hello quick question about mkdir
« Reply #1 on: September 04, 2010, 03:28:22 AM »
How about this:
PHP Code: [Select]
<?php
$username 
$_POST['username'];
$path "users/".$username."/";
//TO DO Add a way where if username is in use fail.
if(!is_dir($path))
{
mkdir($path0755);
echo 
"It Worked"
}
else
{
echo 
"It Failed";

?>
Are you experienced in PHP programming and willing to share your knowledge?
Join us at php help forum!

RobPuck

  • New Member
  • *
  • Posts: 6
  • Karma: +0/-0
    • View Profile
Re: Hello quick question about mkdir
« Reply #2 on: September 04, 2010, 05:56:55 PM »
Thank you That makes sence. How ever When i check the folder on the dedicated server I see it has  the folder users.  when the user registers it should make a folder users/$username/
 
That way each user has a unique folder located on the dedicated server.
 
Example:
 
PHP Code: [Select]
<?php
$username 
$_POST['username'];
$path "users/".$username."/";
if(!
is_dir($path))
{
mkdir($path0755);//To do make sure the folder is created as a unique user folder 
echo "It Worked There is now on the dedicated server a folder called [url=http://wiistream.net/users/Mancent/]http://wiistream.net/users/Mancent/]http://wiistream.net/users/Mancent/]http://wiistream.net/users/Mancent/[/url]"
}
else
{
echo 
"It Failed";

?>

 
 
« Last Edit: September 04, 2010, 05:59:37 PM by RobPuck »

RobPuck

  • New Member
  • *
  • Posts: 6
  • Karma: +0/-0
    • View Profile
Re: Hello quick question about mkdir
« Reply #3 on: September 05, 2010, 12:43:23 PM »
it worked perfectly thank you guys for the help.
 
PHP Code: [Select]
 
 
<?php
include "connect.php";
$username $_POST['username'];
$firstname $_POST['firstname'];
$lastname $_POST['lastname'];
$youremail $_POST['youremail'];
$password $_POST['password'];
$sql mysql_query("SELECT youremail FROM accounts WHERE youremail = '$youremail'");
$rows mysql_num_rows($sql);
//function sha1_password($firstname,$password){$firstname = strtoupper($firstname); $password = strtoupper($password); return //SHA1($firstname.':'.$password);}
//$new_password = sha1_password($firstname,$password); 
if($rows 0)
{
echo 
"&msgText=Registered Failed!\n";
return 
FALSE;
}
else
{
echo 
"&msgText=Successfully registered!\n";
//$wow_mangos = mysql_query("INSERT INTO account (firstname,sha_pass_hash,gmlevel,email,expansion) VALUES //('$firstname','$new_password','0','$email','0')") or die(mysql_error());
$launcher mysql_query("INSERT INTO accounts (username,firstname,lastname,password,youremail) VALUES ('$username','$firstname','$lastname','$password','$youremail')") or die(mysql_error());
$path "../users/".$username."/";
mkdir($path0755);
return 
FALSE;
}
?>