Skip to content
Advertisement

How can I create a folder in php named as user register and link in mysql?

How can I create a folder in PHP named as per username at registration and link in MySQL? After that, I want to upload files as per the user and upload them to the user’s folder.

Advertisement

Answer

Hi You can try something like this

<?php 
if(isset($_POST['submit'])){
    $name= trim($_POST['submit']);
    $email= trim($_POST['email']);
    $username= trim($_POST['username']);
    $password= trim($_POST['password']);
    if($name && $email && $username && password){
    // do what ever you want to do like insert into db etc
    $dirname = "path to you file/".$username;
    mkdir($dirname);        
    }   
}

?>
<form  method='post'>
<legend>Register</legend>
Your Full Name*:<input type='text' name='name'  maxlength="50" /></br>
Email Address*: <input type='text' name='email'' maxlength="50" /></br>
UserName*: <input type='text' name='username' maxlength="50" /></br>
Password*: <input type='password' name='password' maxlength="50" /></br>
<input type='submit' name='submit' value='Submit' />
</form>

for more info about mkdir please read http://php.net/manual/en/function.mkdir.php

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement