我有一个PHP表单,其中创建了一个表中的服务器上的文件夹中的所有文件,并且创建的每一行都分配了一个复选框,用于决定哪些文件将被删除或共享等。每行给出一个名称checkbox[$rownumber]
来区分每个,然后当单击一个按钮,目前为了确保我可以得到它的工作,它只是打印行被选中 - 但我不能得到这个加工。PHP从复选框中获取选定的表行
首先,与行从服务器表中创建的,这是代码,它正确地创建它们,因为我希望
<?php
if(isset($_REQUEST['deleteFile']))
{var_dump($_REQUEST);
if(isset($_POST['checkbox']))
{
print_r($_POST);
}
}
?>
<form name="mainHomescreen" action="MainHomescreen.php" method="POST">
<nav>
<input type="text" name="Search" value="Search" style = "color:#888;" onFocus="inputFocus(this)" onBlur="inputBlur(this)"/>
</nav>
<sidebar>
<input type="button" value="Create Folder" onClick="createFolder()"/>
<input type="button" value="Download Selected Files/Folders" onClick=" "/>
<input type="button" value="Encrypt Selected" onClick="encrypt()"/><br>
<input type="button" value="Share Selected" onClick="shareFolder()"/>
<!-- upload a file -->
<div id="fileUpload">
<div id="uploadPopup">
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" id="uploadForm" method="post" name="uploadForm" enctype="multipart/form-data">
Select file to upload: <input name="fileUpload" type="file" /><br />
<input type="submit" value="Upload File" name="submitFile"/>
</form>
</div>
</div>
<input type="button" name="upload" value="Upload File" onClick="showUpload()"/>
<input type="submit" value="Delete" name="deleteFile"/>
<input type="button" value="Rename" onClick=" "/><br>
<input type="button" value="Password Protect Folder/ File" onClick=" "/><br><br>
</sidebar>
<article>
<span class="error"><?php echo $error;?></span>
<table id="detailView" style="width:100%">
<!-- php to create table -->
<?php
//open file names
$dir = opendir("/home/a1962403/public_html/files");
$filearray = array(array(array()));
echo '<table cellpadding="10" cellspacing="0" style="width:100%">';
echo '
<tr>
<th> </th>
<th>File</th>
<th>Date</th>
<th>Size</th>
</tr>
';
$rownumber = 0;
//List files in directory
while (($file = readdir($dir)) !== false)
{
//gets the file date, string needed decoding otherwise throws error.
$date = @filemtime($file);
$date = date("F d Y H:i:s.", filemtime(utf8_decode("/home/a1962403/public_html/files/$file")));
$size = filesize("/home/a1962403/public_html/files/$file") . ' bytes';
$rownumber = $rownumber + 1;
//prints a table row
echo '<tr class="bottomline">';
echo "<td><input type='checkbox' name='checkbox[$rownumber]' value='[$rownumber]' </td>";
echo "<td>$file</td>";
echo "<td>$date</td>";
echo "<td>$size</td>";
echo '</tr>';
}
echo '</table>';
closedir($dir);
?>
</article>
</form>
</body>
</html>
由此,我有一个提交按钮被称为“DELETEFILE”,这正如我刚才所说的那样,我想要使用它,只是为了确保它能够正常工作而获得所选内容,但实际上并没有给我任何输出,因此不胜感激。
'isset()'检查后'var_dump($ _ REQUEST)'的输出是什么? – RST 2014-12-07 14:11:05
if(isset_REQUEST ['deleteFile']))它是数组(4){[“Search”] => string(6)“Search”[“fileUpload”] => string(0)“”[“deleteFile”] => string(6)“Delete”[“siteowner”] => string(1)“1”} – Navvy 2014-12-07 14:13:37
你能展示更多的代码吗?完整的“表格”。 – RST 2014-12-07 14:27:44