Hey everyone,

So I've got some some code for creating a directory (folder) but forgot to implement the option with creating another folder within a folder that was already created and then displaying that hierarchy on the same page. Here is what I have so far but I can post more code if it's needed down the line, if I've forgotten something.

HTML:

Code:
<form id="form1" name="form1" method="post" action="" style="margin:0px;">
        
    <label for="category_title_box">New Category Title</label><br />
		  <input name="category_title_box" type="text" id="category_title_box" size="20" />
          <br />
	  <br />
		   Select a current Category:
		   <select id="Category_Select" name="Category_Select" height="27px">
			<option value="" selected="selected">-----</option>
				<?php 
					foreach(glob(dirname(__FILE__) . '/files/*') as $filename){
						$filename = basename($filename);
						echo "<option value='" . $filename . "'>".$filename."</option>";
					}
				?>
		   </select>
		   <br />

          <input name="button" type="submit" class="button_190" id="button" value="Add category" style="margin-top:10px;" />
</form>
The PHP along with the HTML:

PHP Code:
// add new category
if(isset($_POST['category_title_box']) and $_POST['category_title_box']!=''){
    
    
$new_category_title string_to_file_name($_POST['category_title_box']);
    
    
mkdir('files/'.$new_category_title);
    
    
header("Location: ".$gallery_url."/admin-categories?message=category added&message_type=success");
    exit;
}
// creates a 'category' folder within a 'category' folder
elseif(file_exists($old_category_title) && $filename == true){
    
    
$new_category_title string_to_file_name($_POST['category_title_box']);
    
    
mkdir('files/'.$old_category_title.'/'.$new_category_title);
    
    
header("Location: ".$gallery_url."/admin-categories?message=category added&message_type=success");
    exit;

I've been looking at this for hours and my brain is sort of tired, so if I've missed something or completely messed it up, it's probably because I don't have fresh eyes.

Thank you for helping!