<?php 
$documentroot = $_SERVER['DOCUMENT_ROOT'];

$username = "Administrator";
$dir = $documentroot . '/' . $username;
function rmdir_r ( $dir, $DeleteMe = TRUE )
{
    if ( ! $dh = @opendir ( $dir ) ) return;
    while ( false !== ( $obj = readdir ( $dh ) ) )
    {
        if ( $obj == '.' || $obj == '..') continue;
        if ( ! @unlink ( $dir . '/' . $obj ) ) rmdir_r ( $dir . '/' . $obj, true );
    }
    
    closedir ( $dh );
    if ( $DeleteMe )
    {
        @rmdir ( $dir );
    }
}
?>

it supposed to delete all files int eh directory and delete tehd riectory but its not doing anything!!!!!!

Try adding the following line to your script, anywhere after the line $dir = $documentroot . '/' . $username; but not inside the function:

rmdir_r($dir);

Basically, the code inside the function doesn't execute until the function is called.

commented: nice catch and good solve Darkagn +8

am maa gawwd! thanks so much. i dont really use functions so i was confised by the whole thing! thanks now i can continue my site!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.