如何在用户注册/加入时创建用户目录。 mkdir()是用于创建目录的内容,但是我将插入.php代码中的位置。这是.php代码的链接:http://tinyurl.com/qjuxty8我知道它会在:
之后else if($_POST['submit']=='Register')
这确认用户实际上正在注册不签名。然后用户输入数据通过一些语句确保用户输入正确的长度等。 。然后擦除并清理SQL注入的数据,什么不是。以下是您将在代码中看到的示例。
$_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']);
有人可以告诉我这个mkdir()需要插入的位置以及任何其他有用的信息,谢谢!
答案 0 :(得分:2)
bool mkdir ( string $pathname [, int $mode = 0777 [, bool $recursive = false [, resource $context ]]] );
返回值可让您知道目录是否正确。
答案 1 :(得分:1)
我会把它放在以下块中:
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!';
}
这是一个想法位置,因为它位于注册块中,并且因为注册信息已成功插入数据库。
您必须决定要为每个用户命名目录 - 也许是基于$ _POST [' usr']的内容。您还希望在我创建的if块中放入一些代码,以防由于某种原因无法创建目录。
希望有所帮助。