<?PHP
class couty{
   public function write ($a,$b){
       @session_start();
       if(!(isset($_SESSION[`login`]) && $_SESSION[`login`] != ``)){
         echo "you must Logged in to create a PHP file";
       }
       else{
            file_put_contents($a,$b);
            exit;
       }
}
}
$c = `<!DOCTYPE HTML><HTML>
<head><title></title></head>
<body></body>
</HTML>`;
if($_SERVER[`REQUEST_METHOD`] == `POST`){
   $new = trim($_POST[`coutyv`]);
   $dir = (mkdir(`folder/$new`));
   $d = new couty();
   $d->write(`$dir/$new.php`,$c);
}
?>
<form method = `post` action = ``>
<input type = `text` name = `coutyv`/>
<input type = `submit` name = `submit`/>
</form> 
            Asked
            
        
        
            Active
            
        
            Viewed 5,743 times
        
    -6
            
            
         
    
    
        nickb
        
- 59,313
- 13
- 108
- 143
 
    
    
        user2398999
        
- 1
- 1
- 1
- 
                    1your code is crappy, consider of rewrite the script – Sam May 19 '13 at 14:37
- 
                    The error message pretty much says it all ? – adeneo May 19 '13 at 14:37
- 
                    Why are all your quotes like this `? They should be like this '. Also, your code have a lot of issues. Start by inspecting the individual lines of it to see if they work. – likeitlikeit May 20 '13 at 00:28
- 
                    One often runs into this error, and to quickly troubleshoot it, follow these steps : http://stackoverflow.com/a/36577021/2873507 – Vic Seedoubleyew Apr 12 '16 at 16:52
2 Answers
2
            
            
        Your problem is in here . Check if you have these folders or not. anyway your code is not good
  $dir = (mkdir(`folder/$new`));
   $d = new couty();
   $d->write(`$dir/$new.php`,$c);
 
    
    
        Yogus
        
- 2,307
- 5
- 20
- 38
0
            
            
        Few things I would do
- Rename your variables from $d, $a, $c to meaningful names - > $new_directory, $output_filename, etc
- Check that $new is infact a valid name.
- Check that mkdir creates the directory successfully.
- Add error handling for all situations in which it fails.
Could be, or might happen in the future:
$dir = (mkdir(`folder/$new`));  <--- $new might be bad / folder might be bad / call might fail
$d->write(`$dir/$new.php`,$c);  <--- maybe the $dir/$new.php generated a bad path.
// future potential errors:
$new = trim($_POST[`coutyv`]); <---- new might not exist, might be invalid, contain invalid 
 
    
    
        Dory Zidon
        
- 10,497
- 2
- 25
- 39
- 
                    There is now a troubleshooting checklist for this frequent error here : stackoverflow.com/a/36577021/2873507 – Vic Seedoubleyew Apr 12 '16 at 16:52