-4

When I want to do folder for the member who registered into my site Inside this folder is a folder for photos and the main file of the member. this is problem :-

The first folder is done with the member name successfully but the photo folder and the profile page of the member do not succeed. thank you ..... this is my code I changed the code by the guy who helped me but the same problem exists The first folder is successfully completed The problem is in file settings, folders, images, and index

<?php
$us = "";
 if(isset($_POST['username'])){ $us= $_POST['username']; }

 if(isset($_POST['username'])){
        mkdir("../profiles/$us", 0777, true);
        mkdir("../profiles/$us/images", 0777, true);
        $filename = "../profiles/$us/index.php";
        $ourFileName = $filename;
        $ourFileHandle = fopen($ourFileName, 'w');

        $written = "
        <html>
        <body>
        <?php
        echo \"hi man \";
        </body>
        </html>
        ";
        fwrite($ourFileHandle, $written);
        fclose($ourFileHandle);
        $myfile = fopen("../profiles/$us/setting.php", "w") or die("Unable to open file!");
        fwrite($myfile, $txt);
        $txt = "Minnie Mouse\n";
        fwrite($myfile, $txt);
        fclose($myfile);

} ?>

1 Answers1

0

You cant assign $us = $_POST["username"] inside of brackets and then use $us again later.

Anything inside of brackets is constrainted within those brackets.

You have to define $us = "" outside of the scope of the IF statement on your first statement.

<?php
     $us = "";
     if(isset($_POST['username'])){ $us= $_POST['username']; }

     if(isset($_POST['username'])){

          etc etc
}
mike510a
  • 2,102
  • 1
  • 11
  • 27
  • Thank you but the same problem exists The first folder is successfully completed The problem is in file settings, folders, images, and index – محمد عادل May 25 '17 at 16:27