the-dream
03-14-2007, 11:10 PM
Ok i have 3 file i have index.php. What index.php does is it creates a directory based on a url variable. so if it was index.php?dir=thedream it would creat a dir called thedream. it also creates a file called index.html in there and copys over 2 files edit.php and update.php.
Here is the code:
index.php
<?php
$dir = $_GET['dir'];
if(file_exists($dir)) {
echo "The Directory ".$dir." Already Exists!";
}
else {
mkdir(''.$dir.'', 0777);
if(file_exists($dir)) {
echo "The Directory ".$dir." Was Created Susessfully!";
$File = "".$dir."/index.html";
$Handle = fopen($File, 'w');
$html = "No Profile Created Yet!";
fwrite($Handle, $html);
fclose($Handle);
chmod(''.$dir.'/index.html', '0777');
if(file_exists(''.$dir.'/index.html')) {
echo "<br />";
echo "Your Profile Page Was Created Sucsessfully!";
copy('edit.php', ''.$dir.'/edit.php');
copy('update.php', ''.$dir.'/update.php');
}
else {
echo "<br />";
echo "Sorry, Your Profile Was Not Created Sucsessfully";
}
}
else {
echo "Sorry, The Directory ".$dir." Was Not Created!";
}
}
?>
ok so thats index.php
edit.php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>Edit Profile</title>
</head>
<body>
<b>Edit Profile:</b><br /><br />
Content (HTML):<br />
<form action="update.php" method="post">
<textarea cols="50" rows="5"></textarea><br />
<input type="submit" value="Save Profile!" /> <input type="reset" value="Reset Form!" />
</form>
<br /><br />
<b>Currunt Profile:</b><br /><br />
<?php readfile('index.html'); ?>
</body>
</html>
and last
update.php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>Saving...</title>
</head>
<body>
<b>Saving:</b><br /><br />
<?php
$html = $_POST['profile'];
$File = "/index.html";
$Handle = fopen($File, 'w');
fwrite($Handle, $html);
fclose($Handle);
echo('Saved!');
?>
</body>
</html>
It creates the dir fine and copy's over the files fine but when you try to edit it you don't get any errors but it doesn't work! I can't figure out why!!! Please help.
Any help would be greatly appreciated!
Thank You!
~ Christian ( the-dream )
Sorry For Not Naming This Post Right! It Will Not Happen Again!
Here is the code:
index.php
<?php
$dir = $_GET['dir'];
if(file_exists($dir)) {
echo "The Directory ".$dir." Already Exists!";
}
else {
mkdir(''.$dir.'', 0777);
if(file_exists($dir)) {
echo "The Directory ".$dir." Was Created Susessfully!";
$File = "".$dir."/index.html";
$Handle = fopen($File, 'w');
$html = "No Profile Created Yet!";
fwrite($Handle, $html);
fclose($Handle);
chmod(''.$dir.'/index.html', '0777');
if(file_exists(''.$dir.'/index.html')) {
echo "<br />";
echo "Your Profile Page Was Created Sucsessfully!";
copy('edit.php', ''.$dir.'/edit.php');
copy('update.php', ''.$dir.'/update.php');
}
else {
echo "<br />";
echo "Sorry, Your Profile Was Not Created Sucsessfully";
}
}
else {
echo "Sorry, The Directory ".$dir." Was Not Created!";
}
}
?>
ok so thats index.php
edit.php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>Edit Profile</title>
</head>
<body>
<b>Edit Profile:</b><br /><br />
Content (HTML):<br />
<form action="update.php" method="post">
<textarea cols="50" rows="5"></textarea><br />
<input type="submit" value="Save Profile!" /> <input type="reset" value="Reset Form!" />
</form>
<br /><br />
<b>Currunt Profile:</b><br /><br />
<?php readfile('index.html'); ?>
</body>
</html>
and last
update.php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>Saving...</title>
</head>
<body>
<b>Saving:</b><br /><br />
<?php
$html = $_POST['profile'];
$File = "/index.html";
$Handle = fopen($File, 'w');
fwrite($Handle, $html);
fclose($Handle);
echo('Saved!');
?>
</body>
</html>
It creates the dir fine and copy's over the files fine but when you try to edit it you don't get any errors but it doesn't work! I can't figure out why!!! Please help.
Any help would be greatly appreciated!
Thank You!
~ Christian ( the-dream )
Sorry For Not Naming This Post Right! It Will Not Happen Again!