I have my register form and when some one registers I want to create a file with the name of there user id, then I want to right a index.php with code that will redirect to the main site.
the location I need the folder to create is example.com/uploads this will be for there images and stuff..
the issue I am having is it refuses to create the folder.
function create_user($email, $full_name, $job_title, $password){
if (email_exists($email)) {
return false;
} else {
$hashed_password = password_hash($password, PASSWORD_BCRYPT);
$db = dbconnect();
$stmt = $db->prepare('INSERT INTO users(Email, FullName, JobTitle, Bio, Password, ValidationCode, Active) VALUES (?,?,?,?,?,?,?)');
$stmt->bind_param('sssssss', $email, $full_name, $job_title, $bio, $hashed_password, $validation_code, $active);
$stmt->execute();
$last_row = $stmt->insert_id;
$stmt->close();
$MainFolder ="uploads";
$dir = $stmt->insert_id;
$file_to_write = 'index.php';
if( is_dir($dir) === false ){
mkdir($dir);
}
$file = fopen($MainFolder.'/'. $dir . '/' . $file_to_write,"w");
// write content into
fwrite($file,"<?php header('location: http://example.com');");
return true;
}
}