0

您好,我正在尝试在 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);

应该可以正常工作,还是我错过了一个小细节?

4

1 回答 1

0

删除引号。

mkdir($userPath, 0777);
于 2013-06-30T14:32:41.167 回答