Pages: [1]   Go Down
Author Topic: mkdir problem, can I get a hand? T.T  (Read 40 times)
brandon
Newbie
*

Karma: +0/-0
Offline Offline

Posts: 2


« on: July 27, 2010, 07:54:23 AM »

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:
<?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:
$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
Report to moderator   Logged

cwarcarblue11
Jr. Member
**

Karma: +0/-0
Online Online

Posts: 18



WWW
« Reply #1 on: August 05, 2010, 11:08:03 AM »

First of all, when joining different variables, don't use a comma, use a period. Like this:
Code:
$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:
<form method="post">
<input type="submit" name="button" value="Make Directory" />
</form>
<?php if(isset($_POST['button']))
{
mkdir($pathname$modetrue);
}
?>
Report to moderator   Logged

Pages: [1]   Go Up
Print
 
Jump to:  

Powered by SMF 1.1.10 | SMF © 2006-2009, Simple Machines LLC | Theme Kani By Fussilet

Page created in 0.032 seconds with 21 queries.