MHovet Posted March 16, 2010 Share Posted March 16, 2010 Hello, Kinda new to this site, but I need help. I have a page that can view all the files in a directory on my server but I can not get it to delete selected files with checkboxes. Anyway here is my code, any help is appreciated. <?php session_start(); if($_SESSION['user-agent'] != $_SERVER['HTTP_USER_AGENT']){ die ("noauth"); } if($_SESSION['auth']!=1){ die ("noauth"); } require_once($_SERVER['DOCUMENT_ROOT'].'/pagestructure/common_noauth.php5'); require_once($_SERVER['DOCUMENT_ROOT'].'/db/dbc.php5'); require_once('dbost.php5'); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>FiST</title> <meta http-equiv="Content-Type" content="text/html;charset=utf-8" /> <link rel="stylesheet" type="text/css" href="../css/fnp3.css" /> <link rel="stylesheet" type="text/css" href="../css/fist.css" /> <script language="Javascript" type="text/javascript" src="../pagestructure/bbox.js"></script> </head> <body> <?php echo DoHeader(1); echo DoContainerTopLid(1); ?> <div class="ContainerContents"> <?php //Since this file is part of a web application, verify permission for that application. if($_SESSION['FIST']==''){ echo '<p>FiST is not an application that you have permission to use.</p>'.PHP_EOL; } else { //Show the application. ?> <div id="applicationHeader"> <?php require('fist_header.php5'); ?> </div> <div id="applicationInterface"> <div class="BBoxFt"> <?php echo table_list($_SESSION['FIST']); ?> </div> <div class="BBox"> <div class="BBoxBd"> <form> <?php $dir = opendir('uploads/'); echo '<ul>'; while ($read = readdir($dir)){ if ($read!='.' && $read!='..'){ echo '<li><a href="uploads/'.$read.'" target="_blank">'.$read.' </a>'; echo ' (<input type="checkbox" name="Del" value='.$read.' />Delete)'; } } echo '<br /><br />'; echo '<a href="download.php5">Delete Selected Files</a>'; echo '</ul>'; closedir($dir); ?> </form> </div> </div> </div><!-- end AppInterface --> <div id="applicationFooter"> <?php require('fist_footer.php5'); ?> </div> <?php } ?> </div><!-- end container contents --> <?php echo DoContainerBottomLid(1); echo DoFooter(1); ?> </body> </html> Link to comment https://forums.phpfreaks.com/topic/195494-php-delete-with-checkboxes/ Share on other sites More sharing options...
AdRock Posted March 17, 2010 Share Posted March 17, 2010 If you're using a form to diplay the checkboxes, why aren't you using a submit button so when you get the $_POST from the button, you can unset all the files by the $_POST['Del'] if(isset($_POST['submit'])) { foreach($_POST['Del'] as $del) { //code to unset the files } } Haven't tested it but the thoery is there Link to comment https://forums.phpfreaks.com/topic/195494-php-delete-with-checkboxes/#findComment-1027367 Share on other sites More sharing options...
MHovet Posted March 17, 2010 Author Share Posted March 17, 2010 Thanks for the reply, I am kind of a newbie to php. So I inserted the code you posted and I just get redirected back to the original page when I click on it. I think I need a different button that points to the unset command. but I am not sure how to do that. Link to comment https://forums.phpfreaks.com/topic/195494-php-delete-with-checkboxes/#findComment-1027623 Share on other sites More sharing options...
MHovet Posted March 17, 2010 Author Share Posted March 17, 2010 I have tried several different methods, some dealing with form entry and some not. I am almost completely at a loss. Any help would be appreciated. Link to comment https://forums.phpfreaks.com/topic/195494-php-delete-with-checkboxes/#findComment-1027707 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.