http://www.pixel2lif...ry_with_jquery/
I've managed to incorporate a login and an upload feature already, but I'm having trouble figuring out how I can also delete images from the gallery. I'm extremely new to PHP so I don't fully know what all of the function mean or do, but i do have experience with other languages.
As you can see in the tutorial each image is output inside a while using an "echo". What i tried to do in my code is to add a checkbox to each of the images like so:
/* Outputting each image: */ echo ' <div id="pic-'.($i++).'" class="pic" style="top:'.$top.'px;left:'.$left.'px;background:url('.$thumb_directory.'/'.$file.') no-repeat 50% 50%;"><form method="post"><input type="checkbox" name="deleteMe[]"></form> <a class="fancybox" rel="fncbx" href="'.$orig_directory.'/'.$file.'" target="_blank">'.$title.'</a> </div>'; $picCount++; }
This does indeed output every image with a checkbox. I then found some instructions on how to check for "ticked" checkboxes in PHP and wrote this just bellow:
if(isset($_SESSION['loggedin'])) { echo'<form method="post"><input type="submit" name="Submit" value="Delete" id="deleteButton"/></form>'; if(isset($_POST['Submit'])) { foreach($_POST['deleteMe'] as $checked) { echo'hello world i have been $checked'; } } }
However when i push the Delete button I get:
Warning: Invalid argument supplied for foreach() in /home/muzosroc/public_html/mediaPHP.php on line 158
From what i understand of PHP, that means that the type of variable which foreach is calling is not an array.
However I thought $_POST was supposed to be an array. I'm fairly confused. Could someone clear this up please? Any ideas?
Thanks =].