Jump to content

Creating username directories


Recommended Posts

I am looking to create directories inside of an "uploads" folder on my server based on the username of the person upon activation of their account..this will be where their uploads will reside. I am not a programmer and know very little php...here is where I believe I would need to integrate the mkdir() but please tell me if Im wrong and if anyone could make this happen for me by posting an example I would love you until my wife told me to stop..lmao Thanks

 

register.php:

 

<?
include_once("header.php");
include_once("class/member.class.php");

$user = new Member();

$note = "";


if (isset($_GET["c"]))
{
	if ($user->Active($_GET["c"]))
	{
		$confirm = "Thank you! Your membership has been confirmed.";
	}else
	{
		$confirm = "Invalid active code.";
	}

	$template->set_filenames(array("body" => "confirm.html"));
	$template->assign_vars(array(
		'COMFIRMMESS'=> "<div style='font-size: 13px; font-family: arial, helvetica;'>".$confirm."</div>"
	));

	$template->pparse("body");
}
else
{
	$ok = 0;
	if(isset($_POST['register']))
	{
		//Check valid registration
		$ok = 1;
		if (!isset($_POST["username"])|| strlen($_POST["username"])<3 || strlen($_POST["username"])>16)
		{
			$username_alert = "<img src = '".$template_dir."/images/alert.gif'> Username must be between 3 and 16 characters long";
			$ok = 0;
		}else
			$username_alert = "";

		if (!isset($_POST["password"])|| strlen($_POST["password"])<=0)
		{
			$password_alert = "<img src = '".$template_dir."/images/alert.gif'> Missing password";
			$ok = 0;
		}else
			if ($_POST["repassword"] != $_POST["password"])
			{
				$repassword_alert = "<img src = '".$template_dir."/images/alert.gif'> Retype password doesn't match with password";
				$ok = 0;
			}else
			{
				$repassword_alert = $password_alert = "";
			}

		if (!isset($_POST["email"])|| $_POST["email"] == "" || !CheckEmail($_POST["email"]))
		{
			$email_alert = "<img src = '".$template_dir."/images/alert.gif'> Please enter a valid email address to continue";
			$ok = 0;
		}else
			$email_alert = "";

		if (isset($_POST["semail"]) && $_POST["semail"] != "" && !CheckEmail($_POST["semail"]))
		{
			$semail_alert = "<img src = '".$template_dir."/images/alert.gif'> Invalid email address";
			$ok = 0;
		}else
			$semail_alert = "";

		if (!isset($_POST["country"]) || $_POST["country"] == "")
		{
			$country_alert = "<img src = '".$template_dir."/images/alert.gif'> Please select one";
			$ok = 0;
		}else
			$country_alert = "";
	}

	 // Addnew user
	 //------------------------------------------------------
	 if ($ok == 1)		
	 {
		$ok = 0;

		if ($user->CheckExistsUserName($_POST["username"]))
		{
			$username_alert =  "<img src = '".$template_dir."/images/alert.gif'> Username is already in use";
		}
		else
		if ($user->CheckExistsEmail($_POST["email"]))
		{
			$email_alert =  "<img src = '".$template_dir."/images/alert.gif'> Email is already in use.";
		}
		else
		{ //Save data
			$members_status = 0;
			$member_activationcode = md5(time());
	  
			$user->AddNew($_POST['username'], $_POST['password'], $_POST['realname'], $_POST['email'],
				$_POST['address'], $_POST['country'] , $_POST['pemail'], $_POST['semail'] , time(), $members_status, $member_activationcode, $_POST["ref"]);

			//Gui mail thong bao
			$to = $_POST['email'];
			$subject = 'Action Required: Membership Activation' ;
			$body = str_replace("{ACTIVE_LINK}", "<a href=".$webroot."register.php?c=". $member_activationcode."'>".$webroot."register.php?c=". $member_activationcode."</a>", REGMAILDETAIL);	
			$headers = "Content-Type: text/html; charset=iso-8859-1\n";
			@mail($to, $subject, $body, $headers);

			//Gui mail to admin
			$body = str_replace("{SIGNUP_TIME}", date("m/d/Y", time()), REG_ADMIN_INFORM_DETAIL);
			$body = str_replace("{USERNAME}", $_POST['username'], $body);
			$body = str_replace("{EMAIL}", $_POST['email'], $body);
			@mail($admin_email, REG_ADMIN_INFORM_SUBJECT, $body, $headers);

			//    redirect("login.php");
			$template->set_filenames(array("body" => "confirm.html"));	 
			  
			$template->assign_vars(array(
					'COMFIRMMESS'=> "<div style='font-size: 13px; font-family: arial, helvetica;'>
						<b>Thank you for registering </b><br><br>
						Please check mail to active your account</div>"
			));  

			$template->pparse("body");
			$ok = 1;
		}
	}

	if ($ok == 0)
	{
		$template->set_filenames(array("body" => "register.html"));

		$country = ($_POST["country"] == "")?"<option value='' selected>Please Select One</option>":
		  "<option value='".$_POST["country"]."' selected>".$_POST["country"]."</option>";

		$template->assign_vars(array(
				'ERROR' => $error,
				'USERNAMEALERT' => $username_alert,
				'PASSWORDALERT' => $password_alert,
				'REPASSWORDALERT' => $repassword_alert,

				'EMAILALERT' => $email_alert,
				'PEMAILALERT' => $pemail_alert,
				'SEMAILALERT' => $semail_alert,
				'COUNTRYALERT' => $country_alert,

				'USERNAME' => $_POST["username"],
				'PASSWORD' => $_POST["password"],
				'REPASSWORD' => $_POST["repassword"],
				'EMAIL' => $_POST["email"],
				'PEMAIL' => $_POST["pemail"],
				'SEMAIL' => $_POST["semail"],

				'REALNAME' => $_POST["realname"],
				'ADDRESS' => $_POST["address"],
				'COUNTRY' => $country,
				'REF' => $suid,
				'NOTE' => $note
		));        	
			  
		$template->pparse("body");
	}
}

include_once ("footer.php");
?>    

 

hmmm not sure if Im on the right track with this...

if($user->Active($this->mkdir("uploads/".$user->username, 0711)) {
$this->setError( 1, 'Failed to create directory "' . $this->elementDir() . '"' );
return false;
} 

 

Link to comment
Share on other sites

I'm not sure that makes sense. You're checking if the user of a mkdir function (which returns a boolean value) is active? ???

 

Where you confirmed the membership, use mkdir to create the directory.

if ($user->Active($_GET["c"])) {
         $confirm = "Thank you! Your membership has been confirmed.";
         mkdir('/path/to/uploads/foldername', 0711);
}

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.