I am new to php code, this is my first one. Here I list the contents of a directory and list it with checkboxes. My final goal is to be able to make one or more selections and delete them. But I am unable to retrieve the value of the select boxes. My return value is empty. (no error message). Please, Can you point me on the right path? Thanks
My index.php
<head>
<!-- JS -->
<script type="text/javascript" src="./js.js"></script>
<!-- CSS -->
<link rel="stylesheet" type="text/css" href="./css/css.css" />
</head>
<form>
<fieldset>
<br><legend>select files to delete :</legend>
<form method="POST" action="index.php">
<?php
$directory = "./tmp";
$list = array_slice(scandir ($directory), 2);
foreach ($list as $file) {
$value= "./tmp/$file";
if (is_file ($value)){ // files only
echo "
<input type='checkbox' name='chk[]' value=$value>$file<br>
";
}
}
?>
<br><input type="submit" name="button" value="DELETE FILES" />
</form>
<!-- return selected checkboxes -->
<h1>$_POST</h1>
<?php
if(isset($_POST["button"]))
{
if (isset($_POST['chk'])){
var_dump($_POST);
}
}
?>
</fieldset>
</form>
Aucun commentaire:
Enregistrer un commentaire