If you are taking input from a user to use in a shell command, you need to run it through escapeshellarg() to make sure they aren't trying to hack your machine to do things it shouldn't by putting an entire script into the variable, which is pretty easy to do in Unix.
Then there are several different commands that will let you execute a command and return / not return output.
So, assuming you got $username from a form...
$username=escapeshellarg($username);
$exec="rmdir $username";
print "Now running command: \"$exec\"";
$result=$exec; # Backtick op OR
$result=exec($exec); # Returns last line OR
$result=system($exec); # Returns all output