milointeractive Posted July 27, 2006 Share Posted July 27, 2006 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! Quote Link to comment https://forums.phpfreaks.com/topic/15831-need-some-guidance/ Share on other sites More sharing options...
tomfmason Posted July 27, 2006 Share Posted July 27, 2006 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 = "<?phpecho \"You sucessfuly created the index.php\"?>"; $handle = fopen($filename, "x+");fwrite($handle, $somecontent);fclose($handle);//now the detail$file = "$dir/details.php";$content = "<?phpecho \"You sucessfuly created the details.php\"?>"; $h = fopen($file, "x+");fwrite($h, $content);fclose($h);?>[/code] Hope this helps,Tom Quote Link to comment https://forums.phpfreaks.com/topic/15831-need-some-guidance/#findComment-64812 Share on other sites More sharing options...
milointeractive Posted July 27, 2006 Author Share Posted July 27, 2006 Tom -- Excellent! Thanks so much for the reply! I am going to see what I can put together! Quote Link to comment https://forums.phpfreaks.com/topic/15831-need-some-guidance/#findComment-64867 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.