duanrang9348 2015-08-28 19:21
浏览 46
已采纳

在用户注册/加入后创建用户目录(0777)

How to create a user directory upon the user registering/joining. mkdir() is what would be used to create the directory but where in the .php code would I insert it. Here is a link to the .php code: http://tinyurl.com/qjuxty8 I know it would go after the:

else if($_POST['submit']=='Register')

This confirms that the user is in fact registering not signing it. The user input data is then ran through some statements making sure the user is inputting the correct length etc. . . and then the data is scrubed and cleaned for SQL Injection and what not. Here is an example of what you will see in the code.

$_POST['email'] = mysql_real_escape_string($_POST['email']);
$_POST['usr'] = mysql_real_escape_string($_POST['usr']);
$_POST['firstN'] = mysql_real_escape_string($_POST['firstN']);
$_POST['lastN'] = mysql_real_escape_string($_POST['lastN']);
$_POST['country'] = mysql_real_escape_string($_POST['country']);
$_POST['state'] = mysql_real_escape_string($_POST['state']);
$_POST['city'] = mysql_real_escape_string($_POST['city']);
$_POST['jobtitle'] = mysql_real_escape_string($_POST['jobtitle']);
$_POST['website'] = mysql_real_escape_string($_POST['website']);

Could someone please give me an idea on where this mkdir() needs to be inserted and any other useful information that could help, Thank You!

  • 写回答

2条回答 默认 最新

  • duancheng6500 2015-08-28 20:15
    关注

    I would put it in the following block:

    if(mysql_affected_rows($link)==1)
    { 
    
        //I WOULD PUT IT RIGHT HERE
        $makeDir = mkdir("YOUR DIRECTORY NAME HERE");
        if(!$makeDir)
        {
           //DO SOMETHING IF THE DIRECTORY FAILED TO BE CREATED
        }
    
        send_mail(  'admin@.com',
                    $_POST['email'],
                    'Registration .com - Your New PassCode',
                    'Congratulations! You are now a memeber of  and can start to share your views. You can login at the homepage, top-right with this passcode: '.$pass);
    
        $_SESSION['msg']['reg-success']='You will recieve your PassCode via E-mail, approx... 5 to 10 minutes!';
    
    }
    

    This is the idea location because it is in the registration block and because the registration information was insert into the database successfully.

    You'll have to decide what you want to name the directory for each user--maybe something based off of $_POST['usr']. You'll also want to put some code in the if block I created in case the directory fails to be created for some reason.

    Hope that helps.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥60 要数控稳压电源测试数据
  • ¥15 能帮我写下这个编程吗
  • ¥15 ikuai客户端l2tp协议链接报终止15信号和无法将p.p.p6转换为我的l2tp线路
  • ¥15 经gamit解算的cors站数据再经globk网平差得到的坐标做形变分析
  • ¥15 GD32 SPI通信时我从机原样返回收到的数据怎么弄?
  • ¥15 phython读取excel表格报错 ^7个 SyntaxError: invalid syntax 语句报错
  • ¥20 @microsoft/fetch-event-source 流式响应问题
  • ¥15 ogg dd trandata 报错
  • ¥15 高缺失率数据如何选择填充方式
  • ¥50 potsgresql15备份问题