Reset PSB™ Status Code Meanings to Original Settings
The reset-meanings-to-original-meanings.php script lets administrators reset the PSB™ administrator's PSB™ status code meanings to the original meanings they had at sign-up. Editing PSB™ status code meanings is done in another script.
In reseting the meanings in the PSB™ administrator's status code meanings table, the configure.php file 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 other variable getting POSTed from this meanings table reseting page to itself. Note that if the Administrator 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 pushed the "Reset Meanings" button on the form. The 'go' variable is set with "Y" to signal the administrator giving the go-ahead on the table reseting.
Once the $A variable is set, the PHP script resets the status code meanings in the PSB™ administrator's status code meanings table where all the PSB™ administrator's status code meanings are stored, to the original meanings they had at sign-up. Note that "DROP TABLE $B" is the table query used to get rid of the current meanings table, "CREATE TABLE $B . . ." (plus a few other statements) remakes the table—although it is empty, and "INSERT INTO $B (sorter, meaning) . . . . . ." (and a whole lot of data strings) loads up the table like it used to be at sign-up. And it only works if the administrator's username was located in the members table when he logged in. Note that in MySQL queries, single quotes are used around data variables, but when there are variables that represent table names, (i.e., $B), no quotes should be used.
Every administrator has an editable table of PSB™ status code meanings that uses his user name as part of its title, and a PSB™ table that also uses his user name as part of its title. The latter contains First Names, IDs, Comments, and Status Codes, which the psb.php script (the actual PSB™) uses to represent current statuses and comments. These are the data of the members of the administrator's PSB™ group. $B=$U."_meaning" is used for assembling the table name used in the table updating.
If the table gets reset successfully, you get a message to that effect. Success is detected by whether or not the old table if found and dropped, paving the way for a new one to be created and filled. Once the reset is done, there's a button to let the administrator return to the Administrators Page. Note that JSON is used to pass the user name from PHP to JavaScript and then it gets POSTed back to PHP by the form in this script as well as to the Administrator page. This keeps the user logged in so he need not login constantly as he uses various editing scripts.
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=windows-1252">
<TITLE>Reset Meanings to Original Meanings</TITLE>
<meta name="description" content="Reset Meanings to Original Meanings">
<meta name="keywords" content="Reset Meanings to Original Meanings,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:450px;left:270px;border:1px solid black;background-color:#eee;'>
<?php
include_once"configure.php";
$U=$_POST['username'];
$A=$_POST['go'];
if (!isset($U)) {
echo '<script language="javascript">alert("Please login.");
window.location="login.php"; </script>';
}
$B=$U."_meaning";
$result = mysql_query("SELECT * FROM $B") or die(mysql_error());
echo "<table border='1' width='462'>";
echo "<tr><th>Status Code</th><th width='412'>Meaning</th></tr>";
while($row = mysql_fetch_array($result)) {
echo "<tr><td>";
$q=$row['sorter']-1;if ($q<10){$q=strval($q);$q="0".$q;}
echo $q;
echo "</td><td>";
echo $row['meaning'];
echo "</td></tr>";
}
echo "</table>";
if (isset($A)) {
$retval1 = mysql_query("DROP TABLE $B") or die(mysql_error());
if ($retval1){unset($A);
echo '<script language="javascript">alert("The change was successfully accomplished.");</script>';}
else{echo '<script language="javascript">alert("The change was unsuccessful.");</script>';}
$sql = "CREATE TABLE $B
(
sorter int(3) NOT NULL,
meaning varchar(57) NOT NULL,
PRIMARY KEY(sorter)
)";
// Execute query
mysql_query($sql);
mysql_query("INSERT INTO $B (sorter, meaning)
VALUES ('1','Alone (do not disturb)'),('2','Alone thinking'),('3','Alone with someone'),('4','Alone creating'),('5','Alone sleeping'),('6','Alone studying'),('7','Alone exercising'),('8','Alone feelings (sad or lonely or depressed)'),('9','Alone feelings (anxious or confused or fearful or upset)'),('10','Alone feelings (need help)'),('11','Want nurturing'),('12','Will nurture'),('13','Could nurture'),('14','I am a scheduled caregiver'),('15','Sick - need care'),('16','Sick - have care'),('17','Want stories'),('18','Will read stories'),('19','Want massage'),('20','I am being nurtured'),('21','Want P.E.T. training'),('22','Will train re: P.E.T.'),('23','Need to do problem solving'),('24','Will help problem-solve'),('25','Need active listening'),('26','Will active listen'),('27','Doing authoritative parenting activity - not P.E.T.'),('28','Want help with discipline'),('29','Will give help with discipline'),('30','Doing P.E.T. activity'),('31','Want advice'),('32','Will advise'),('33','Want group discussion'),('34','Want to talk with female'),('35','Want to talk with male'),('36','Want adult company'),('37','Want child company'),('38','Want to play'),('39','Want to play game(s)'),('40','I am in meeting'),('41','Let Us Coordinate MC party'),('42','Let Us Coordinate MC big dinner'),('43','Let Us Coordinate MC all-MC meeting'),('44','Let Us Coordinate MC MC projects'),('45','Let Us Coordinate MC music'),('46','Let Us Coordinate MC creative projects'),('47','Let Us Coordinate MC activity - open to possibilities'),('48','Let Us Coordinate MC movie in theater'),('49','Let Us Coordinate MC DVD movie on TV'),('50','I am in MC coordinating meeting'),('51','Let Us Coordinate shopping - food'),('52','Let Us Coordinate shopping - clothes'),('53','Let Us Coordinate shopping - other'),('54','Let Us Coordinate going to library'),('55','Let Us Coordinate going to concert'),('56','Let Us Coordinate going to movie'),('57','Let Us Coordinate playing sports'),('58','Let Us Coordinate seeing sporting event'),('59','Let Us Coordinate exercise'),('60','Let Us Coordinate other'),('61','I am Out at school or daycare'),('62','I am Out at work'),('63','I am Out at shopping'),('64','I am Out at library'),('65','I am Out at entertainment'),('66','I am Out with friends or date'),('67','I am Out at hospital'),('68','I am Out at vacation - out of town'),('69','I am Out at doctor'),('70','I am Out at other'),('71','Want Ride north - A.M.'),('72','Want Ride north - P.M.'),('73','Want Ride south - A.M.'),('74','Want Ride south - P.M.'),('75','Want Ride east - A.M.'),('76','Want Ride east - P.M.'),('77','Want Ride west - A.M.'),('78','Want Ride west - P.M.'),('79','Want Ride motorcycle OK'),('80','Want Passenger(s) - I will drive'),('81','Want help with project'),('82','Will help with project'),('83','Want tutor in music'),('84','Want tutor in math'),('85','Want tutor in science'),('86','Want tutor in languages'),('87','Want tutor in English or literature'),('88','Want tutor in history'),('89','Want tutor in taxes'),('90','Will tutor'),('91','Need pet caretaker'),('92','Am texting'),('93','Text me'),('94','Am emailing'),('95','Email me'),('96','Am IMing'),('97','IM me'),('98','Surfing the Net'),('99','Writing a letter'),('100','All is well')
");
?>
<div style='position:absolute;top:0px;left:0px;border:1px solid black;background-color:#eee;'>
<?php
$result = mysql_query("SELECT * FROM $B") or die(mysql_error());
echo "<table border='1' width='462'>";
echo "<tr><th>Status Code</th><th width='412'>Meaning</th></tr>";
while($row = mysql_fetch_array($result)) {
echo "<tr><td>";
$q=$row['sorter']-1;if ($q<10){$q=strval($q);$q="0".$q;}
echo $q;
echo "</td><td>";
echo $row['meaning'];
echo "</td></tr>";
}
echo "</table>";
?>
</div>
<?php
}
mysql_close();
?>
</div>
<h1>Reset Meanings to Original Meanings</h1>
<div id='pw' style='position:absolute;top:150px;left:270px;width:462px'><table style="background-color:#8aa;border-color:#00f" border='6' cellspacing=0 cellpadding=6><tr><td>
<form id='formpw' name="formpw" method="post" action="reset-meanings-to-original-meanings.php" onsubmit="return validatego()">
<input type="hidden" name="go" value="Y">
<input type="hidden" name="username" value=" ">
<input type="submit" value="Reset Meanings"><br><br>
</form></td></tr></table>
<br><br>
<form style='margin-left:100px' 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>