Search code examples
phpauthenticationregistration

Link files so they get edited equal


I have mage a login system on my website. I've done it so when someone signs up, they get their own folder with a file in it. Yhe file is called profile.php. The profile.php file is directed in the root folder, and is copied into the users folder.

Here is a small part of my code:

try {
    $path = "users/".$row['ID']."/";
    if(!is_dir($path)){
        mkdir($path);
    }
    copy('profile.php',$path . 'profile.php');
} catch(PDOException $ex) {
    die('error');
}

I wondered if it was possible to change all the profile.php files in all the foldesr at once when i edit the root file.

Does anybody know?


Solution

  • I acctually managed to solve the problem by myself. I created i new file called profilepage.php, and the code in this file is:

    <?php
        require ($_SERVER['DOCUMENT_ROOT']. '/profile.php');
    

    Then i edited the register file so it copies the profilepage.php instead.

    try {
        $path = "users/".$row['ID']."/";
        if(!is_dir($path)){
            mkdir($path);
        }
        copy('profilepage.php',$path . 'profilepage.php');
    } catch(PDOException $ex) {
    die('error');
    }