I know to use mkdir(); to make a folder but I want to do a little more that that.
This is what I want to do:
When a user signs-up, a folder is created at domain.com/profiles/[the username]
and a standard php file is copied there from domain.com/profiles/defaultprofile.php
but the file is renamed to index.php. After that is done I want to make another folder at
domain.com/~[username], and then create another php file, which has a header which redirects
to domain.com/profiles/[the username].... which if i need to make another default page I can, but
I don't know how to make it so that it would foward to the right directory.
How would I do this all...
PHP - Username to Folder [SOLVED]
Moderator: General Moderators
- tecktalkcm0391
- DevNet Resident
- Posts: 1030
- Joined: Fri May 26, 2006 9:25 am
- Location: Florida
PHP - Username to Folder [SOLVED]
Last edited by tecktalkcm0391 on Mon Jun 12, 2006 6:39 pm, edited 1 time in total.
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
- tecktalkcm0391
- DevNet Resident
- Posts: 1030
- Joined: Fri May 26, 2006 9:25 am
- Location: Florida
- jayshields
- DevNet Resident
- Posts: 1912
- Joined: Mon Aug 22, 2005 12:11 pm
- Location: Leeds/Manchester, England
Code: Select all
mkdir($username);
$filename = $username.'/index.php';
$somecontent = "<?\n".'header("Location: domain.com/profiles/'.$username.'")'."\n?>\n";
if (!$handle = fopen($filename, 'x')) {
echo "Cannot open file ($filename)";
exit;
}
if (fwrite($handle, $somecontent) === FALSE) {
echo "Cannot write to file ($filename)";
exit;
}
echo "created profile for ".$username;
fclose($handle);- tecktalkcm0391
- DevNet Resident
- Posts: 1030
- Joined: Fri May 26, 2006 9:25 am
- Location: Florida