The script is supposed to delete the guestbook entries, but when you submit nothing happens. I did a print_r($_POST) and it was completely empty and when i say empty i mean that there is nothing on the page except for the following:
<html>
<head>
<title>-=On A Dead Machine=-</title>
<link rel="stylesheet" type="text/css" href="/common/common.css">
</head>
<body bgcolor="#000000">
</body>
</html>
I don't know why the $_POST isn't posting to itself. Any help would be GREATLY appreciated considering i have been sick for the past couple of days and my though t process hasn't exactly been the best in the world!
//required class(gb class - definitely not //finished yet
<?
define ('OADM_BASE', dirname(FILE).'/../../common');
require_once(OADM_BASE.'/classes.php');
require_once(OADM_BASE.'/common.inc');
?>
<?
class Guestbook extends ADUO {
var $gbEntries = array();
var $successMsg = array();
var $start = '';
var $total = '';
var $prev = '';
var $next = '';
function listEntries() {
$this->start = $_REQUEST['start'];
$this->dbHandle();
$this->db->dbcnx();
$sql = "SELECT gb_id, name, message ";
$sql .= "FROM guestbook ORDER BY gb_id DESC";
$this->db->query($sql);
while ($data = $this->db->data_as_object()) {
$this->gbEntries[] = array (
'GB Id' => $data->gb_id,
'Name' => $data->name,
'Message' => $data->message
);
}
}//end listEntries
function deleteGuestbookEntries() {
$this->dbHandle();
$this->db->dbcnx();
$id = $_POST['id'];
while (list($k, $v) = each($id)) {
$sql = "DELETE FROM guestbook ";
$sql .= "WHERE gb_id = $v";
$this->_db->query($sql);
if (mysql_affected_rows() > 0 ) {
$this->successMsg[] = "Deletion successful for $id";
}
}
}//end deleteGuestbookEntries()
}//end Guestbook Class
?>
#end class
//begin gb_admin.php
<?session_start();
if (!isset($_SESSION['username'])) {
header("Location: restricted.php");
} else {
define('OADM_BASE',dirname(FILE).'/../common');
define('ADMIN_BASE',dirname(FILE).'/lib');
require_once OADM_BASE.'/common.inc';
require_once ADMIN_BASE.'/Guestbook.php';
?>
<html>
<head>
<title><?=$pageTitle?></title>
<link rel="stylesheet" type="text/css" href="/common/common.css">
</head>
<body bgcolor="#000000">
<?if ($REQUEST['task'] == 'delete'):?>
<?
$gb = new Guestbook;
$gb->listEntries();
?>
<?
if ($POST['submit'] == 'Delete Entries') {
print "This is a test\n";
$gb->deleteGuestbookEntries();
if (is_array($gb->successMsg) && !empty($gb->sucessMsg)):?>
<table border="0" cellpadding="2" cellspacing="0">
<?foreach($gb->successMsg as $msg):?>
<tr>
<td><?=$msg?></td>
</tr>
<?endforeach?>
</table>
<?endif?>
<?
}
?>
<form name="deleteGB" action="<?=$_SERVER['PHP_SELF']?>" method="post">
<table border="1" cellpadding="2" cellspacing="0">
<?foreach($gb->gbEntries as $entry):?>
<tr>
<td>
<strong>Delete?</strong>
<input type="checkbox" name="id[]" value="<?=$entry['GB Id']?>"></td>
<td><?=$entry['Message']?></td>
</tr>
<tr>
<td colspan="2"> </td>
</tr>
<?endforeach?>
<tr>
<td><input type="submit" name="submit" value="Delete Entries"></td>
</tr>
</table>
</form>
<?endif?>
</body>
</html>
<?}?>