Jump to content

Archived

This topic is now archived and is closed to further replies.

milointeractive

Need some guidance...

Recommended Posts

Hello. I am getting more comfortable with PHP/MySQL in building CMS systems for clients. I want to embark on a new project that requires a bit more expertise. Here is what I am trying to accomplish:

When a user creates a link in their admin area (simple php/mysql add, modify, delete type of system), I need to create a directory based on what they title their link. I would then need two files to be added in the directory (an index file, and a detail file) both of which would need to be dynamically assigned the ID of the recently inserted "link" record.

Can anyone point me in the right direction or include some URLs to some useful information?

Thanks!

Share this post


Link to post
Share on other sites
Ok what I would do is use [code=php:0]mkdir[/code] to create the directory. And then usen [code=php:0]fopen[/code] to create the files. I would do something like this.

you can create a link to this file like this [code=php:0]<a href="thisfile.php?var=$var">Add your Var</a>[/code]

[code=php:0]<?php
$var = preg_replace('/[^\x09\x0A\x0D\x20-\x7F]/e', '"&#".ord($0).";"', $var);

if (!$var) {
    echo "You did not enter a variable";
    include('yourform.php');
    exit;
}
$dir = "path/to/new/dir/$var";
mkdir("$dir", 0700);

if (!mkdir) {
    echo "unable to create the directory. You may not have to proper permissions to do so";
    include('yourform.php');
    exit;
}
//the index.php
$filename = "$dir/index.php";
$somecontent = "<?php
echo \"You sucessfuly created the index.php\"
?>";
$handle = fopen($filename, "x+");
fwrite($handle, $somecontent);
fclose($handle);

//now the detail
$file = "$dir/details.php";
$content = "<?php
echo \"You sucessfuly created the details.php\"
?>";
$h = fopen($file, "x+");
fwrite($h, $content);
fclose($h);
?>[/code]

Hope this helps,
Tom

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.