zero-perfoliate
zero-perfoliate

Author Topic: mkdir problem, can I get a hand? T.T  (Read 199 times)

Offline brandon

  • New PHP Members
  • Posts: 2
  • Karma: +0/-0
mkdir problem, can I get a hand? T.T
« on: July 27, 2010, 04:54:23 PM »
I know, I know, I'm new here, but I really need help with this. The more I learn, the more I can help others, right? ^^;

Code: [Select]
<?php
$username 
'timmy';
$pathname '/profiles/' $username;
$mode '0777';
?>

<html>
<head>
<title>Test</title>
</head>
<body>
<input type="button" value="Make Directory" onClick="<?php mkdir($pathname$modetrue)?>">
</body>
</html>

Why won't this work? Gives me an error.

 I know it's not that I'm using the PHP code inside the onClick="" parameter, because it works if I don't use the string $pathname in place of "/profiles/username/"  -- however, this will not allow me to make a dir of the user's username (hence $username).

 I'll explain what I'm trying to do.

 I am slowly but surely learning PHP, so in this struggle I wish to apply the ever-growing knowledge to building a social network for role players.
 I won't go into what role players are, if you know that's awesome but it's irrelevant.
 This bit of code is supposed to take the username, and create a sub-directory inside the folder "profiles/", and this sub-directory should be the username of the person clicking the button.
 As for now, I am using 'timmy' as an example username, and I got the mkdir() function to work fine. However, I cannot get the mkdir() function to include the string "$username" in the string "$pathname", or to do anything with strings at all.
 In other words, I want the user to create a new folder inside the already-existing folder "profiles/", which will be named the same as the string "$username", which is, for this example, "timmy". Hence,

Code: [Select]
$username = 'timmy';
.

Any help would be greatly appreciated ^^ Even if you don't help, a reply will keep the post alive for someone who knows more than Id o about what they're doing to lend a hand! =D

Offline cwarcarblue11

  • PHP Problem Solvers
  • *****
  • Posts: 112
  • Karma: +1/-0
    • C2C Technology
Re: mkdir problem, can I get a hand? T.T
« Reply #1 on: August 05, 2010, 08:08:03 PM »
First of all, when joining different variables, don't use a comma, use a period. Like this:
Code: [Select]
$pathname = '/profiles/' . $username;
Also, php is server-side, which means that you can only process code in the loading of the page. So you cannot make an onclick event like that. However, you could do something like this:
Code: [Select]
<form method="post">
<input type="submit" name="button" value="Make Directory" />
</form>
<?php if(isset($_POST['button']))
{
mkdir($pathname$modetrue);
}
?>

 

zero-perfoliate