Jump to content

Deleting selected things with Checkboxs


dean7

Recommended Posts

Hi all, I've just finished sorting my Inbox code for my website which all works apart from deleting more than one message at a time.

 

 

if (isset($_POST['Deleteselected'])){
foreach($_POST['radio'] as $value) {
   $numm++;
mysql_query("DELETE FROM inbox WHERE id='$value'");
} 
echo "<table class='table' width='30%' align='center' cellpadding='0' border='1' cellspacing='0'>
<tr>
<td class='header' align='center'>Success</td>
</tr>
<tr>
<td align='center'>$numm messages deleted!</td>
</tr>
</table><br />	";
}
    $row = mysql_fetch_array($get_messages2);
if($row['read'] == 0)
{
    echo '<tr><td><input class="input" type="checkbox" name="radio[]" value="' . $row['id'] . '"></td><td width="40%" align="center"><a href="rmessage.php?messageid=' . $row['id'] . '">' . $row['title'] . '</a> <font color="red"><strong>**</font> Unread <font color="red">**</strong></font></td><td width="40%" align="center"><a href="profile.php?viewuser=' . $row['from'] . '">' . $row['from'] . '</a></td><td align="center"><a href="?delete='.$row['id'].'"><strong>Delete</strong></td></tr>';
}else{
echo '<tr><td><input class="input" type="checkbox" name="radio[]" value="' . $row['id'] . '"></td><td width="40%" align="center"><a href="rmessage.php?messageid=' . $row['id'] . '">' . $row['title'] . '</a></td><td width="40%" align="center"><a href="profile.php?viewuser=' . $row['from'] . '">' . $row['from'] . '</a></td><td align="center"><a href="?delete='.$row['id'].'"><strong>Delete</strong></td>';
}

 

This is the form which has the button:

 

<form action='' method='POST' name='thishere'>
<table width="25%" cellpadding="0" align="center" cellspacing="0" border="1" class="table">
	<tr>
		<td class="header" align="center" colspan="2">Control Panel</td>
	</tr>
	<tr>
		<td align='left' width='50%'> <input name='Deleteselected' class='button' type='submit' id='Deleteselected' value='Delete Selected'></td>
	</tr>

 

When I select the check box and the press "Delete Selected" It says that the message is deleted but it accually still there and hasnt been deleted.

 

Anyone see why its doing that?

 

Thanks for any help provided :)

Link to comment
https://forums.phpfreaks.com/topic/220578-deleting-selected-things-with-checkboxs/
Share on other sites

i dont really get what you really want but as far as i notice

 

If you are going to use $_POST['radio'] then you have to put your radio inside <form></form>

 

and the another thing is that you can try to fill the form action with this <form action="<?php echo $_SERVER['PHP_SELF'];?>">

 

hope it helps

i dont really get what you really want but as far as i notice

 

If you are going to use $_POST['radio'] then you have to put your radio inside <form></form>

 

and the another thing is that you can try to fill the form action with this <form action="<?php echo $_SERVER['PHP_SELF'];?>">

 

hope it helps

Thanks for your reply. Yeah it was because my Radio wernt isnt the <form> tags. Didnt see how I missed that.

 

Thanks anyway :D

. . . and the another thing is that you can try to fill the form action with this <form action="<?php echo $_SERVER['PHP_SELF'];?>">

 

Except using that introduces a known XSS vulnerability. Use action="" to submit a form to itself.

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.