i'm writing [at least trying to] a database script in php. people can enter info about themselves and create an account [if you want to call it that]
well, in the admin.php, i'm having trouble being able to delete more than one person at a time. it has a checkbox next to each account name, and i'd like it to be able to delete all accounts that are checked. right now it just deletes the lowest checked account:
here's the code i've written, but it's not quite working correctly, only deletes the most recently checked box. the main troublesome code is near the bottom, in $action == "member_remove"
well, in the admin.php, i'm having trouble being able to delete more than one person at a time. it has a checkbox next to each account name, and i'd like it to be able to delete all accounts that are checked. right now it just deletes the lowest checked account:
here's the code i've written, but it's not quite working correctly, only deletes the most recently checked box. the main troublesome code is near the bottom, in $action == "member_remove"
PHP:
<?php
if (file_exists("config.php")) {
include("config.php");
}
else {
?>
<html><body><font color="red">config.php</font> is absent.<br></body></html>
<?
exit;
}
if (!$action) {
ShowAdminHeader();
?>
<form action="<? echo("$PHP_SELF"); ?>" method="post">
<input type="hidden" name="action" value="member_remove">
<table width="100%" cellpadding="3" cellspacing="3" border="0">
<tr bgcolor="#dddddd">
<td>
<font size="1" face="verdana">
<br>
</font>
</td>
<td>
<font size="1" face="verdana">
<b>Account Name</b><br>
</font>
</td>
<td>
<font size="1" face="verdana">
<b>Email</b><br>
</font>
</td>
<td>
<font size="1" face="verdana">
<b>Password</b><br>
</font>
</td>
<td>
<font size="1" face="verdana">
<b>Created</b><br>
</font>
</td>
<td>
<font size="1" face="verdana">
<b>Last Modified</b><br>
</font>
</td>
</tr>
<?
$dir="$members";
$a=opendir("$dir");
while ($account_name = readdir($a)) {
$fp = fopen("$dir/$account_name", 'r');
$data = fread($fp, filesize("$dir/$account_name"));
list($epoch,$created,$modified,$email,$pass,$info) = explode("\n",$data);
fclose ($fp);
if(ereg("^\.",$domain)) continue;
echo "\n<tr>\n";
echo "<td bgcolor=\"#eeeeee\">";
echo "<input type=\"checkbox\" name=\"remove\" value=\"$account_name\">";
echo "</td>\n";
echo "<td>";
echo "<font size=\"1\" face=\"verdana\">$account_name</font>";
echo "</td>\n";
echo "<td bgcolor=\"#eeeeee\">";
echo "<font size=\"1\" face=\"verdana\"><a href=\"mailto:$email\">Send Email</a></font>";
echo "</td>\n";
echo "<td>";
echo "<font size=\"1\" face=\"verdana\">$pass</font>";
echo "</td>\n";
echo "<td bgcolor=\"#eeeeee\">";
echo "<font size=\"1\" face=\"verdana\">$created</font>";
echo "</td>\n";
echo "<td>";
echo "<font size=\"1\" face=\"verdana\">$created</font>";
echo "</td>\n";
echo "</tr>\n\n";
}
closedir($a);
?>
</table>
<br>
<input type="submit" value="Remove Selected Members"><br>
</form>
<?
ShowAdminFooter();
exit;
}
elseif (($action == "member_remove") && eregi("$PHP_SELF", $referer)) {
while ($remove) {
if ($remove) {
$delete = unlink("$members/$remove");
}
if ($delete) {
ShowAdminHeader();
?>
<font color="red"><? echo("$remove"); ?></font> was successfully removed.<br>
<?
ShowAdminFooter();
exit;
}
else {
ShowAdminHeader();
?>
<font color="red"><? echo("$remove"); ?></font> was not removed.<br>
<?
ShowAdminFooter();
exit;
}
}
}
else {
header("Location: [url]http://[/url]$HTTP_HOST$PHP_SELF");
exit;
}
?>
Last edited: