I have a script (I found this scrip browsing the Internet) that looks in a directory for images and displays each image as a thumbnail. I modified the script and I have included a form and for each image there is a checkmark.
gallery.php
<html>
<head></head>
<body>
<?php
// start form
echo "<FORM method=post action=sendemail.php>";
// start table
echo "<table>";
// define directory path
$dir = ".";
// iterate through files
// look for JPEGs
if (is_dir($dir)) {
if ($dh = opendir($dir)) {
while (($file = readdir($dh)) !== false) {
if (preg_match("/.jpg/", $file)) {
// read EXIF headers
$exif = exif_read_data($file, 0, true);
echo "<tr>";
// get thumbnail
// link to full image
echo "<td valign=top><a href=$dir/$file><image src=thumbnail.php?file=$file></a><td>";
echo "<td valign=top><font size=-1>";
// get file name
echo "File: <b>" . $exif['FILE']['FileName'] . "</b><br/>";
//form element
$count == $count ++;
echo "<input type=checkbox name=photo[] value=" . $exif['FILE']['FileName'] . " />" . $exif['FILE']['FileName'] . "<br />";
// get timestamp
echo "Timestamp: " . $exif['IFD0']['DateTime'] . "<br/>";
// get image dimensions
echo "Dimensions: " . $exif['COMPUTED']['Height'] . " x " . $exif['COMPUTED']['Height'] . " <br/>";
// get camera make and model
echo "Camera: " . $exif['IFD0']['Model'];
echo "</font></td>";
echo "</tr>";
}
}
closedir($dh);
}
}
echo "</table>";
echo "Enter your email address: <input type=textbox name=email><br />";
//echo "<input type=hidden name=checked value=$value>";
echo "<br /><input type=submit value=Submit />";
echo "</form>";
?>
</body>
</html>
I tried many different ways to create an array or something similar
This is the line to create the checkbox in two different form
//form element
echo "<input type=checkbox name=photo[] value=" .
//form element
$count == $count ++;
echo "<input type=checkbox name=photo$count value=" .
With the second method I can make the element name = photo1, photo2, etc. but not with photo[]
anyway... where I have most of the problem is when I try to send the email message.
sendmail.php
<?php
$to = "info@photopr.com";
$subject = "Photo Selections";
$email = $_REQUEST['email'] ;
$message = $_REQUEST['message'] ;
$photoqty = $_REQUEST['photoqty'];
//$photo=$_REQUEST['photo'];
while ($count < $photoqty))
{
$message+= $_REQUEST['photo' . $count];
$count++;
}
$headers = "From: $email";
$sent = mail($to, $subject, $message, $headers) ;
if($sent)
{print "Your mail was sent successfully"; }
else
{print "We encountered an error sending your mail"; }
?>
I tried many different ways to do this with no luck. I tried while or foreach... not luck.
Why I want is to send an email with the checked image names to an email.
Any help will be most appreciated.