I just started PHP a week ago.
The Idea
The page I am making gives information on products. Each product has it’s own folder named after it’s database ID number. In this folder are files that belong to the product.
How it works
On the main page you can add a new product. You give it a name and the PHP gives it an ID number. Then there is a big fat button that links them back to the main page. There they have to search for the product. Once they access the product's edit page they have to hit another big button that creates new directories and uploads files to that directory before they can edit the product's page.
Ideally
As you can see it is not very user-friendly.
Ideally the user hits the submit button on the create new product page and the script automatically creates the folders and uploads the files. The thing is, the script dose not know the ID number of the product yet.
Uploads new product to database (the folowing is only an example)
Code: Select all
<?
$Name=$_POST['new_product];
.
.
.
$addProduct = "INSERT INTO Product (Name) VALUES ('".$Name."')";
$result = mysql_query($addProduct);
?>Creating dir and upload files (the folowing is only an example)
Code: Select all
<?
$input=$_POST['productID'];
mkdir("Product/".$input."/", 0700);
mkdir("Product/".$input."/Images/", 0700);
$file = 'AAA/BBB/CCC.xxx';
$newfile = 'DDD'.$input.'/CCC.xxx';
if (!copy($file, $newfile)) {
echo "failed to copy $file...\n";
}
?>