Close PSB™ Administrator Account
The close-account.php script closes the account of a PSB™ administrator, dumping his record from the members file as well as dumping both MySQL tables with his particular user name in them. The first, username_psb (substitute his actual user name for the word username), contains the first names of all people in his group, their ID numbers, their current PSB™ status code, and their current comment. The second, username_meaning (substitute his actual user name for the word username), contains the current status code meanings for the 100 status codes, numbered 00 to 99. These are editable by the administrator.
In closing the account, the configure.php is included to establish server and database connections. Next, we get the username and go variables POSTed to our PHP script, with the username being POSTed from the page that sent us here and the go variable getting POSTed from this account closing page to itself. This latter simply needs any value in order for the operation of closing the account to proceed. One assumes that if an administrator pushes the submit button in the form labeled "Close Your PSB™ Administrator Account", he is serious about account closing. Note that if he is not logged in and therefore his username (stored in $U) is unset, he is sent to the login page. If the $A variable is not set, he has not yet clicked on the "Close Your PSB™ Administrator Account" button. A hidden field with the name of "go"—in the form—is how the "go" value gets POSTed to the PHP script.
Once the $A variable is set, the PHP script dumps his record from the members table, then deletes his two tables in the database. If the tables get dumped successfully, you get a message to that effect and then get sent to the css-resources.com home page. If the administrator has second thoughts about the account closure, he can choose to return to the Administrators Page.
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=windows-1252">
<TITLE>Close PSB™ Administrator Account</TITLE>
<meta name="description" content="Close PSB™ Administrator Account">
<meta name="keywords" content="Close PSB Administrator Account,php,javascript, dhtml, DHTML">
<style type="text/css">
BODY {margin-left:0; margin-right:0; margin-top:0;text-align:left}
p, li {font:13px Verdana; color:black;text-align:left}
h1 {font:bold 28px Verdana; color:black;text-align:center}
h2 {font:bold 24px Verdana;text-align:center}
h3 {font:bold 15px Verdana;}
</style>
</head><body>
<div style='position:absolute;top:50px;left:190px;'>
<?php
include_once"configure.php";
$U=$_POST['username'];
echo "Your user name: ".$U;
$A=$_POST['go'];
if (!isset($U)) {
echo '<script language="javascript">alert("Please login.");
window.location="login.php"; </script>';
}
if (isset($A)) {
mysql_query("DELETE FROM members WHERE username='$U'");
$pName=$U."_psb";
$mName=$U."_meaning";
$retval1 = mysql_query("DROP TABLE $mName") or die(mysql_error());
$retval2 = mysql_query("DROP TABLE $pName") or die(mysql_error());
if ($retval1 && $retval2){
echo '<script language="javascript">alert("Account closure successfully accomplished.");window.location="http://css-resources.com/";</script>';}
else{echo '<script language="javascript">alert("Account closure was unsuccessful.");</script>';}}
mysql_close();
?>
<h1>Close PSB™ Administrator Account</h1>
<div id='pw' style='position:absolute;top:200px;left:0px;width:362px'><table border='0' cellspacing=0 cellpadding=6><tr><td>
<form id='formpw' name="formpw" method="post" action="close-account.php" onsubmit="return validatego()">
<input type="hidden" name="username" value=" ">
<input type="hidden" name="go" value="Y">
<input type="submit" value="Close Your PSB™ Administrator Account">
</form></td></tr></table>
<br><br>
<form style='margin-left:0px' name="MyForm" method="POST" action="administrator-page.php">
<input type="button" value="Return to Administrator Page" onclick="goback()">
<input type="hidden" name="username" value=" ">
</form>
</div>
<script language="javascript">
function goback(){
var u = <?php echo json_encode($U); ?>;
document.MyForm.username.value=u;
document.MyForm.submit();}
function validatego(){
var u = <?php echo json_encode($U); ?>;
document.formpw.username.value=u;}
</script>
</body></html>