Location: PHPKode > projects > NetLink > netlink_os/del_act.php
<?php
if ($yes_del)
{
echo "Deleting records for $act...";
  include("db.php");
  $dbh=mysql_connect ($host,$account,$acc_pw) or die (mysql_error());
  mysql_select_db ($table); 
  $sql="DELETE FROM Accounts WHERE Username='$act'";
  echo "<br/><br/><code>DELETE FROM Accounts<br/>\nWHERE Username='$act';";
  $rs=mysql_query($sql,$dbh);
	$sql_CSS="DELETE FROM CSS WHERE Username='$act'";
  echo "<br/><br/><code>DELETE FROM CSS<br/>\nWHERE Username='$act';";
  $rs_CSS=mysql_query($sql_CSS,$dbh);
mysql_close($dbh);
if ($rs)
  echo "<br/><b>$act records deleted!</b>";
else
  echo "<br/><b><span id='error'>ERROR:</span> Could not delete $act's record.";
echo "<br/><br/>Deleting files for $act...";

function deldir($dir) {
   $dh=opendir($dir);
   while ($file=readdir($dh)) {
       if($file!="." && $file!="..") {
           $fullpath=$dir."/".$file;
           if(!is_dir($fullpath)) {
               unlink($fullpath);
           } else {
               deldir($fullpath);
           }
       }
   }

   closedir($dh);
  
   if(rmdir($dir)) {
       return true;
   } else {
       return false;
   }
}
echo "<br/><br/>rmdir -R 'Users/$act'";
echo "<br/>";
$del_file=deldir("Users/$act");
if ($del_file)
  echo "<b>$act files deleted!</b>";
else
  echo "<b><span id='ERROR:</span> Could not delete $act's files...";

echo "<br/><br/>";
if (($rs==TRUE)&&($del_file==TRUE))
  echo "<b>$act</b> account, records, and files deleted!";
else
  echo "<span id='error'>Error: Sumthin' hickuped!</span>";
}
echo "<br/>\n<br/>\n";
echo "<b>$act's</b> account deleted!<br/>\nAll files are removed from their account, their database records deleted, and their account canceled.";
?>
Return current item: NetLink