Hello I'm new to PHP, here's what I'm haveing trouble with. I'm using php to display a gallery in a directory and delete the images, but I get an error when I try to use the delete button and I don't know why or how to fix it, can anyone help?
Parse error: syntax error, unexpected $end in /delete.php on line 22
Here is the code on the page:
<form name="form1" method="post" action="delete.php">
<?php
$path = "test";
$dir_handle = @opendir($path) or die("Unable to open folder");
while (false !== ($file = readdir($dir_handle))) {
if($file == "index.php")
continue;
if($file == ".")
continue;
if($file == "..")
continue;
echo "<input type=CHECKBOX name=$file>";
echo "<img src='$file' alt='$file'><br />";
}
closedir($dir_handle);
?>
<input type="submit" name="Delete" value="Delete">
</form>
And here is the delete.php code (line 22 is the end of the code ?>):
<?php
$path = "test";
$dir_handle = @opendir($path) or die("Unable to open folder");
//We list the name of the files again, since the name of the checkbox is the same with the name of the file
while (false !== ($file = readdir($dir_handle))) {
if($file == "index.php")
continue;
if($file == ".")
continue;
if($file == "..")
continue;
if(isset($_POST[$file])){
$checkbox = $_POST[$file];
if($checkbox == on) { //checkbox is selected
//Delete the file
if(!unlink($file)) die("Failed to delete file");
}
}
?>