Code: Select all
echo '<form>';
echo '<input name="file_name[]" type="checkbox" id="checkbox[]" value="<? echo $record; ?>"/>';
echo '<br>';
echo "<input name='delete' type=submit id='delete' value='Delete'>";
echo '</form>';
There are a number of problems with this form:
- you've got an echo statement nested inside an echo statement
- Short tags (<?) should not be used
- HTML element IDs should be unique
- $record is an array, so assigning it to the value of the checkbox won't work.
Moreover, when this form is submitted, $_POST will contain file_name (which is an array of... something. Won't work until you fix the value), and delete. That's it.
Code: Select all
$sql = "DELETE FROM images WHERE image_id = :image_id";
}
$stmt = $db->prepare($sql);
$stmt->bindParam(':image_id', $_POST['image_id'], PDO::PARAM_INT);
$_POST['image_id'] is not set. There is no form field called image_id.
Code: Select all
unlink("user-images/".$record['file_name']);
Where is $record coming from?
Code: Select all
$file_name = (isset($_POST['file_name']));
This will evaluate to a boolean, though you don't appear to be using it anywhere.
Code: Select all
$array = array("checkbox" => $_POST['checkbox']); //WOULD I NEED CHANGE THE CHECKBOX TO FILE_NAME ON THIS LINE
What is this meant to be doing?