您好我正在尝试在users /文件夹中创建一个目录。当用户注册vpb_save_details.php时正在打开。并运行mkdir以创建一个用户名为目录名的用户。
用户正常注册但没有创建目录的问题,甚至不是/ user目录。
如果我运行此代码:
<?php
mkdir("blah", 0777);
?>
目录bla已创建,但如果我运行我的代码vpb_save_details.php,则没有任何反应。
这是代码的一部分:
//If the user is validated and every thing is alright, then save the user details and display success message to the user
//otherwise, display error message to the user
if ($vpb_error == '')
{
//Encrypt user information with Base64 before saving them to a file
if(fwrite($vpb_database, "\r\n".base64_encode($fullname)."::::::::::".base64_encode($username)."::::::::::".base64_encode($email)."::::::::::".base64_encode($encrypted_user_password).""))
{
echo '<font style="font-size:0px;">completed</font>';
echo '<div class="info">Congrats <b>'.$fullname.'</b>, you have registered successful. <br>You may now click on the login button to log into your account.<br>Thanks.</div>';
//
// HERE! I create a folder in the users directory with the variable $username as username
//
$newUserName = $username;
$userPath = "users/".$newUserName;
mkdir("$userPath", 0777);
//copy("index.php",$userPath/index.php);
}
else
{
echo '<div class="info">Sorry, your account creation was unsuccessful, please try again (1).</div>';
}
}
else
{
echo $vpb_error;
}
fclose($vpb_database);
我完全不知道问题是什么?代码:
$newUserName = $username;
$userPath = "users/".$newUserName;
mkdir("$userPath", 0777);
应该工作得很好,还是我错过了一个小细节?
答案 0 :(得分:0)
删除引号。
mkdir($userPath, 0777);