dean7 Posted December 3, 2010 Share Posted December 3, 2010 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 Quote Link to comment https://forums.phpfreaks.com/topic/220578-deleting-selected-things-with-checkboxs/ Share on other sites More sharing options...
robert_gsfame Posted December 3, 2010 Share Posted December 3, 2010 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 Quote Link to comment https://forums.phpfreaks.com/topic/220578-deleting-selected-things-with-checkboxs/#findComment-1142648 Share on other sites More sharing options...
dean7 Posted December 3, 2010 Author Share Posted December 3, 2010 Quote 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 Quote Link to comment https://forums.phpfreaks.com/topic/220578-deleting-selected-things-with-checkboxs/#findComment-1142668 Share on other sites More sharing options...
Pikachu2000 Posted December 3, 2010 Share Posted December 3, 2010 Quote . . . 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. Quote Link to comment https://forums.phpfreaks.com/topic/220578-deleting-selected-things-with-checkboxs/#findComment-1142680 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.