Arrggh. This is haunting me.
I'n function viewToDelete() i output the information from a database and build a form in order to delete posts. In function delete() i use a form to delete posts. The post is being delete, but this error is given on the form action
deletepost.php
I defined the checkbox with the name "bid" in the form in function viewToDelete(). If the script is being executed, why is this error being recieved?
Thanks
PHP Code:
function viewToDelete(){
$this->connect();
echo "<p align='left'>";
$this->connect();
$query = "SELECT id,author,topic,email,mood,date,entry,np,month FROM blog ORDER BY id DESC";
$result = mysql_query($query) or die(mysql_error());
$rows = mysql_num_rows($result) or die(mysql_error());
if($rows == "0"){ echo "No information in database!"; }
else {
while($row = mysql_fetch_assoc($result)){
$this->id = $row['id'];
$this->author = $row['author'];
$this->topic = $row['topic'];
$this->email = $row['email'];
$this->mood = $row['mood'];
$this->date = $row['date'];
$this->entry = $row['entry'];
echo "<b><font size='3'><span id='title'>$this->topic</span><br></font><font size='2'></b>";
echo "<span id='double'>$this->entry</span>";
echo "<br><i><p align='right'></b> $this->date by <a href='mailto:$this->email'>$this->author</a> | <B>Mood:</b> $this->mood</font></i>\n";
$this->commentsNumber($this->id);
echo '<br /><form action="deletepost.php" method="POST"><input type="checkbox" value="'.$this->id.'" name="bid">Delete Post?<input type="submit" value="Delete"></form>';
echo "<hr noshade color='black' size='1'></p>";
}
}
}
function delete($id){
$this->id = $id;
$this->connect();
$query = "DELETE FROM blog WHERE id='{$this->id}'";
mysql_query($query) or die(mysql_error());
$queery = "DELETE FROM comments WHERE bid='{$this->id}'";
mysql_query($queery) or die(mysql_error());
Header("Location: ?mode=cp&cpmode=deletepost");
}
Notice: Undefined index: bid in c:\server\htdocs\blog\admin\deletepost.php on line 4
PHP Code:
<?php
include_once('../blog.php');
$exe = new blog;
$exe->delete($_POST['bid']);
?>
Thanks
Comment