R
E
S
O
U
R
C
E
S
       Home      Products & Services      Contact Us      Links


WebHatchers will design & develop your site for you.
_______________________

Website Menu Heaven: menus, buttons, etc.
_______________________

Send us your questions.
_______________________

site search by freefind
_______________________

HOME
SEO, Google, Privacy
   and Anonymity
Browser Insanity
JavaScript
Popups and Tooltips
Free Website Search
HTML Form Creator
Animation
Buttons and Menus
Counters
Captchas
Image Uploading
CSS and HTML
PHP
AJAX
XPATH
Website Poll
IM and Texting
Databases—MySQL
   or Not MySQL
Personal Status Boards
Content Management
   Systems
Article Content
   Management Systems
Website Directory
   CMS Systems
Photo Gallery CMS
Forum CMS
Blog CMS
Customer Records
   Management CMS
Address Book CMS
Private Messaging CMS
Chat Room CMS
JavaScript Charts
   and Graphs




Free Personal Status Boards (PSB™)

Free Standard Free PSB

Free PSB Pro Version

Free Social PSB

Free Social PSB Plus (with Email)

Free Business PSB

Free Business PSB Plus (with Email)

PSB demo

Social PSB demo

Business PSB demo

So what's all this PSB stuff about?

Chart comparing business status boards

PSB hosting diagram

PSB Licence Agreement



Copyright © 2002 -
MCS Investments, Inc. sitemap

PSBs, social networking, social evolution, microcommunities, personal status boards
PSBs, social networking, business personal status boards
website design, ecommerce solutions
website menus, buttons, image rotators
Ez-Architect, home design software
the magic carpet and the cement wall, children's adventure book
the squirrel valley railroad, model railroad videos, model train dvds
the deep rock railroad, model railroad videos, model train dvds

Delete Group Member

The delete-group-member.php script lets administrators delete a user first name, and the record it is in, from his psb table. Editing group members or adding group members are done in other scripts.

In deleting a group member name, and the record it is in, from the administrator's psb table, the configure.php is included to establish server and database connections. Next, we get the username and fname variables POSTed to our PHP script, with the username being POSTed from the page that sent us here and the other variables getting POSTed from this member deleting 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 entered data into the form.

Once the $A variable is set with the first name, the PHP script deletes the specified first name, and the record it is in, from the Administrator's psb table where first names, IDs, statuses and comments are stored. To do this, the table gets queried with mysql_query("DELETE FROM $B WHERE Firstname='$A'"); which finds the record in the table and dumps it.

If the table gets edited successfully, you get a message to that effect. Success is detected by a special MySQL function, mysql_affected_rows(). Once the deleting 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.

Note the end of the second script that prints the IDs and First Names into an HTML table:

if ($rc>0){
echo "";
echo " "."<BR>";
echo "";}

This allows the screen to keep looking neat, since the first (pre-edit) table is printed right on top of the second (post-edit) table, and the second table, sans a member, will be shorter, so the old table's end will stick out below the edited table's end. So we simply add a blank line to cover it, if the edit has succeeded, and the problem disappears.

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=windows-1252">
<TITLE>Delete Group Member</TITLE>
<meta name="description" content="Delete Group Member">
<meta name="keywords" content="Delete Group Member,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:370px;border:1px solid black;background-color:#eee;'>

<?php

include_once"configure.php";

$U=$_POST['username'];
$A=$_POST['fname'];

if (!isset($U)) {
echo '<script language="javascript">alert("Please login.");
window.location="login.php"; </script>';
}

$B=$U."_psb";

$result = mysql_query("SELECT * FROM $B") or die(mysql_error());

echo "<table border='1' width='162'>";
echo "<tr><th>ID</th><th>First Name</th></tr>";
while($row = mysql_fetch_array($result)) {
echo "<tr><td>";
echo $row['ID'];
echo "</td><td>";
echo $row['Firstname'];
echo "</td></tr>";
}
echo "</table>";

if (isset($A)) {
mysql_query("DELETE FROM $B WHERE Firstname='$A'");

$rc = mysql_affected_rows();
if ($rc>0){unset($A);
echo '<script language="javascript">alert("The change was successfully accomplished.");</script>';}
else{echo '<script language="javascript">alert("The change was unsuccessful.");</script>';}
?>

<div style='position:absolute;top:0px;left:0px;border:1px solid black;background-color:#eee;'>

<?php

$B=$U."_psb";

$result = mysql_query("SELECT * FROM $B") or die(mysql_error());

echo "<table border='1' width='162'>";
echo "<tr><th>ID</th><th>First Name</th></tr>";
while($row = mysql_fetch_array($result)) {
echo "<tr><td>";
echo $row['ID'];
echo "</td><td>";
echo $row['Firstname'];
echo "</td></tr>";
}
if ($rc>0){
echo "<tr><td>";
echo " "."<BR>";
echo "</td></tr>";}

echo "</table>";

?>

</div>

<?php
}

mysql_close();
?>
</div>

<h1>Delete Group Member</h1>

<div id='pw' style='position:absolute;top:150px;left:370px;width:262px'><table style="background-color:#8aa;border-color:#00f" border='6' cellspacing=0 cellpadding=6><tr><td>
<form id='formpw' name="formpw" method="post" action="delete-group-member.php" onsubmit="return validatefname()">
<label for="First Name"><b>First Name:    </b><input type="text" name="fname" size="12" maxlength="12" value=""></label><br><br>
<input type="hidden" name="username" value=" ">
<input type="submit" value="Delete Group Member"><br><br>
<input type="reset" value="Reset"></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 validatefname(){

var u = <?php echo json_encode($U); ?>;
document.formpw.username.value=u;

var ck_username = /^[A-Za-z0-9_]{1,12}$/;
if (document.formpw.fname.value.search(ck_username)==-1)
{alert("Please only enter letters, numbers and underline for user first names, and enter 1 to 12 characters.");return false}

return true;}

</script>

</body></html>