Jump to content

Delete blab only if the person owns the blab


Glenskie

Recommended Posts

ok so i have this problem , it wont delete the persons post  AKA BLAB here is the code , i want it to delete the specific blab that they want to delete , here is my code

<?php
if (isset($_SESSION['idx']) && $logOptions_id != $id){
$sql_blabs = mysql_query("SELECT id, mem_id, the_blab, blab_date FROM blabbing WHERE mem_id='$id' ORDER BY blab_date DESC LIMIT 20");

while($row = mysql_fetch_array($sql_blabs)){

$blabid = $row["id"];
$uid = $row["mem_id"];
$the_blab = $row["the_blab"];
$the_blab = ($activeLinkObject -> makeActiveLink($the_blab));
$blab_date = $row["blab_date"];
$convertedTime = ($myObject -> convert_datetime($blab_date));
    $whenBlab = ($myObject -> makeAgo($convertedTime));

			$blabberDisplayList .= '
		        <table style="background-color:#FFF; border:#999 1px solid; border-top:none;" cellpadding="5" width="100%">
				<tr>
				<td width="10%" valign="top">' . $blab_pic . '</td>
				<td width="90%" valign="top" style="line-height:1.5em;"><span class="greenColor textsize10">' . $whenBlab . ' <a href="profile.php?id=' . $uid . '">' . $username . '</a> said:</span><br />
            ' . $the_blab . ' </td>
            </tr></table>';

}}
if (isset($_SESSION['idx']) && $logOptions_id == $id){
$sql_blabs = mysql_query("SELECT id, mem_id, the_blab, blab_date FROM blabbing WHERE mem_id='$id' ORDER BY blab_date DESC LIMIT 20");
 {
$sqlDeleteBlabs = mysql_query("SELECT * FROM blabbing WHERE mem_id='$id' ORDER BY blab_date DESC LIMIT 50");
	while ($row = mysql_fetch_array($sqlDeleteBlabs)){
    $blad_id = $row["id"];
if (isset($_POST['deleteBtn'])) {
    foreach ($_POST as $key => $value) {
        $value = urlencode(stripslashes($value));
	if ($key != "deleteBtn") {
$Delete = mysql_query("DELETE FROM blabbing WHERE id='$blad_id' AND mem_id='$id'");
header("location: profile.php?id=$id");
}
}}}
}
while($row = mysql_fetch_array($sql_blabs)){

$blabid = $row["id"];
$uid = $row["mem_id"];
$the_blab = $row["the_blab"];
$the_blab = ($activeLinkObject -> makeActiveLink($the_blab));
$blab_date = $row["blab_date"];
$convertedTime = ($myObject -> convert_datetime($blab_date));
    $whenBlab = ($myObject -> makeAgo($convertedTime));

			$blabberDisplayList .= '
		        <table style="background-color:#FFF; border:#999 1px solid; border-top:none;" cellpadding="5" width="100%">
				<tr>
				<td width="10%" valign="top">' . $blab_pic . '</td>
				<td width="90%" valign="top" style="line-height:1.5em;"><span class="greenColor textsize10">' . $whenBlab . ' <a href="profile.php?id=' . $uid . '">' . $username . '</a> said:</span><br />
            ' . $the_blab . ' <input type="submit" name="Delete" id="$Delete" value="Delete" /></td>
            </tr></table>';
}}
?>

	$Delete = mysql_query("DELETE FROM blabbing WHERE id='$blad_id' AND mem_id='$id'");
header("location: profile.php?id=$id");

 

How do you know if this query succeeded or failed?

 

Also it's very strange that you have a loop over $_POST, and inside the loop you check if the key is NOT deleteBtn.  And then inside that you use two values $blad_id and $id which are not related to the key you found in $_POST at all.  I don't understand the logic of that.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.