zipp Posted July 29, 2007 Share Posted July 29, 2007 Im trying to make a File managment system, I have gotten the files to display properly, now what I am trying to do is have a check box next to each file, that if clicked, when the form is submitted, the file will be deleted. I would like to be able to have more then 1 check box selected. html code (generated by php) <form enctype='multipart/form-data' method='POST' id='del' action='delete.php'> <input type='submit' value='Delete'></th> <tr><td colspan="2"><a href="/admin/admin-xxky.php?dir=upload/jackie">jackie</a></td> </tr> <tr> <td>-->aloud.wav</td> <td style="padding-left:40px;"><input type="checkbox" name="delete"></td> </tr> <tr> <td>-->howto.txt</td> <td style="padding-left:40px;"><input type="checkbox" name="delete"></td> </tr> <tr> <td>-->readme.txt</td> <td style="padding-left:40px;"><input type="checkbox" name="delete"></td> </tr> <tr><td colspan="2"><a href="/admin/admin-xxky.php?dir=upload/test2">test2</a></td> </tr> <tr> <td>-->New Text Document.txt</td> <td style="padding-left:40px;"><input type="checkbox" name="delete"></td> </tr> <tr><td colspan="2"><a href="/admin/admin-xxky.php?dir=upload/test">test</a></td> </tr> <tr> <td>-->New Flash ActionScript File.as</td> <td style="padding-left:40px;"><input type="checkbox" name="delete"></td> </tr> <tr> <td>-->New WinRAR ZIP archive.zip</td> <td style="padding-left:40px;"><input type="checkbox" name="delete"></td> </tr> <tr><td colspan="2"><a href="/admin/admin-xxky.php?dir=upload/tom">tom</a></td> </tr> <tr> <td>-->aloud.wav</td> <td style="padding-left:40px;"><input type="checkbox" name="delete"></td> </tr> <tr> <td>-->howto.txt</td> <td style="padding-left:40px;"><input type="checkbox" name="delete"></td> </tr> <tr> <td>-->readme.txt</td> <td style="padding-left:40px;"><input type="checkbox" name="delete"></td> </tr></table> delete.php code <?php if ($_REQUEST['delete']) { unlink($_REQUEST['delete']); } ?> Quote Link to comment Share on other sites More sharing options...
zq29 Posted July 29, 2007 Share Posted July 29, 2007 Change the name of your checkboxes from delete to delete[]. They will then be sent as an array. Quote Link to comment Share on other sites More sharing options...
yarnold Posted July 29, 2007 Share Posted July 29, 2007 Also if I were you I would replace $_REQUEST with $_POST... It's a little more secure. Quote Link to comment Share on other sites More sharing options...
zipp Posted July 30, 2007 Author Share Posted July 30, 2007 I thought that REQUEST was more secure then POST. thanks for the tip. As soon as I try the delete[] thing, ill edit my post accordingly. **edit** Thank you for your help, both responses where helpful. Topic solved. Quote Link to comment 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.