I have the following code in a form:
<?
for ($n = 0; $n < count($filelist); $n++)
{
printf ("<button type='submit' name='imgnam' value='%s'>", $filelist[$n]);
printf ("<img src='%s' width='100' />", $dirname . $filelist[$n] . ".gif");
print "</button>";
printf ("<br>%s</p>\n", $filelist[$n]);
}
?>
$dirname
contains the directory value $filelist[]
contains all .JPG file names found in the $dirname
directory
This generates the following HTML code:
<button type='submit' name='imgnam' value='File0001'><img src='./Lemmons/10-24-91/File0001.gif' width='100' /></button><br>File0001</p>
<button type='submit' name='imgnam' value='File0002'><img src='./Lemmons/10-24-91/File0002.gif' width='100' /></button><br>File0002</p>
<button type='submit' name='imgnam' value='File0003'><img src='./Lemmons/10-24-91/File0003.gif' width='100' /></button><br>File0003</p>
<button type='submit' name='imgnam' value='File0004'><img src='./Lemmons/10-24-91/File0004.gif' width='100' /></button><br>File0004</p>
<button type='submit' name='imgnam' value='File0005'><img src='./Lemmons/10-24-91/File0005.gif' width='100' /></button><br>File0005</p>
<button type='submit' name='imgnam' value='File0006'><img src='./Lemmons/10-24-91/File0006.gif' width='100' /></button><br>File0006</p>
<button type='submit' name='imgnam' value='File0007'><img src='./Lemmons/10-24-91/File0007.gif' width='100' /></button><br>File0007</p>
</td>
7 buttons are displayed, each with a GIF image. When a button is clicked (ex: button for #0005), FireFox and Safari both show $imgnam
contains the value field of the button clicked, as it should -- in this test case it contains the value File0005
.
IE on the other hand does not. When I display the value of $imgnam
a broken image box is displayed with the properties:
Name: %22
Address: http: //www.pattinson.net/%22./lemons/10-24-92/File0005.gif/%22
Size: Not Available
Dimensions: 100 x 114 pixels
Any idea where this %22 is coming from? What does FFox know that IE doesn't?
The effect of the code can be seen here with values displayed for debugging purposes.
The full code:
<?
##--------------------------------------##
## mainline
{
## These lines display the values coming into the script
print "Username=[" . $username . "] ";
print "Album=[" . $album . "] ";
print "Page=[" . $page . "] ";
print "Image=[" . $imgnam . "] ";
print "Comment=[" . $comment . "]<hr>";
##--- Get the Album level directory
$albhnd = @opendir("./");
if (!$albhnd)
{
print "<b>Album Level not opened </b><br />";
}
else
{
while ($albval = readdir($albhnd))
{
if (!is_file("./" . $albval) &&
($albval != ".") &&
($albval != ".."))
{
$alblist[] = trim($albval);
}
}
closedir($albhnd);
}
if (count($alblist) > 1) sort($alblist);
if (!$album)
{
$album = $alblist[0];
}
##--- Get the Page level directory
$paghnd = @opendir("./" . $album . "/");
if (!$paghnd)
{
print "<b>Page Level not opened </b><br />";
}
else
{
$nopage = true;
while ($pagval = readdir($paghnd))
{
if (!is_file("./" . $pagval) &&
($pagval != ".") &&
($pagval != ".."))
{
$paglist[] = trim($pagval);
if (trim($pagval) == $page) $nopage = false;
}
}
closedir($paghnd);
}
if (count($paglist) > 1) sort($paglist);
if ($nopage) $page = $paglist[0];
$directory = $album . "/" . $page;
$dirname = "./" . $album . "/" . $page . "/";
$filhnd = @opendir($dirname);
if (!$filhnd)
{
printf ("<b>Directory [%s] not opened </b><br />", $dirname);
}
else
{
$chg = 1;
while ($fil = readdir($filhnd))
{
if (is_file($dirname . $fil))
{
$sl = strlen($fil);
$filn = strtok($fil, ".");
$filex= substr($fil, $sl-4, 4);
if ($filex == ".jpg")
{
## -- display the file names as we find them --
print "{" . $filn . "} ";
$filelist[] = trim($filn);
if ($imgnam == $filn) $chg = 0;
}
}
else
{
}
}
closedir($filhnd);
}
print "<br>";
if (count($filelist) > 1) sort($filelist);
if (!$imgnam || $chg == 1)
{
$imgnam = $filelist[0];
}
$imageThmb = $dirname . $imgnam . "sml.jpg";
$imageFile = $dirname . $imgnam . ".jpg";
$comntFile = $dirname . $imgnam . ".txt";
$info_File = $dirname . $imgnam . ".fil";
if ($comment != "")
{
$fp = @fopen($comntFile, "a");
if (!$fp)
{
print "<b>File [$comntFile] was not opened for write</b><br />";
}
else
{
fwrite($fp, "\n" . date('d-M-Y h:i A T') . " -- " . $username . "\n");
fwrite($fp, $comment);
fwrite($fp, "\n");
fclose($fp);
}
}
## Display the values used to generate the page...
print "Username=[" . $username . "] ";
print "Album=[" . $album . "] ";
print "Page=[" . $page . "] ";
print "Directory=[" . $directory . "] ";
print "Image=[" . $imgnam . "] ";
print "DirName=[" . $dirname . "]<br>";
print "FileList=";
for ($n = 0; $n < count($filelist); $n++) print " [" . $filelist[$n] . "] ";
print "<br>Comment=[" . $comment . "] ";
?>
<html>
<head>
<title>Comment on Pix</title>
<style>
H1,H2,H3,H4 { display : inline ; }
</STYLE>
</head>
<body bgcolor='#00D5D5'>
<form method="post" action="index.php">
<input type="hidden" name="imgnam" value="<? print $imgnam ?>" />
<table border="1" cellpadding="8" width="750">
<tr valign="top">
<!----------------------->
<!-- Navigation Column -->
<td rowspan='4' bgcolor="#00fd00" align='center'>
<b>Your Name</b>
<input type='text' value='<? print $username ?>' name='username' />
<hr>
<table border='1' cellpadding='2'><tr><th>
Select Album<br>
<select name="album">
<?
for ($n = 0; $n < count($alblist); $n++)
{
if (trim($alblist[$n]) == $album)
printf ("<option selected value='%s'>%s", trim($alblist[$n]), $alblist[$n]);
else
printf ("<option value='%s'>%s", trim($alblist[$n]), $alblist[$n]);
}
?>
</select>
</th></tr><tr><th>
Select Event
<br>
<select name="page">
<?
for ($n = 0; $n < count($paglist); $n++)
{
if (trim($paglist[$n]) == $page)
printf ("<option selected value='%s'>%s", trim($paglist[$n]), $paglist[$n]);
else
printf ("<option value='%s'>%s", trim($paglist[$n]), $paglist[$n]);
}
?>
</select>
</th></tr><tr><th></th></tr><tr><th>
<button type="submit" />Select Album</button>
</th></tr></table>
<hr>
<?
for ($n = 0; $n < count($filelist); $n++)
{
printf ("<button type='submit' name='imgnam' value='%s'>", $filelist[$n]);
printf ("<img src='%s' width='100' />", $dirname . $filelist[$n] . ".gif");
print "</button>";
printf ("<br>%s</p>\n", $filelist[$n]);
}
?>
</td>
<th colspan='2' height='120'>
<h1>Our Pictures</h1><br>
You are encouraged to generously add as many stories and comments as possible<br>
See <a href='#dir'>instructions</a> at bottom of page<br>
Enjoy
</th>
</tr>
<tr>
<!-- Display Image -->
<td bgcolor="#fd0000" align="center" width="400" height='300'>
Image <B><? print $imgnam ?></B>
<a href="<? print $imageFile; ?>" target='BigPic'>
<img src="<? print $imageFile; ?>" width='400' />
</a><br />
</td>
<!-- Display Existing Comments -->
<th bgcolor="#0000fd" align="center">
<font color="#FFFF00">Current Comments for <? print $imgnam ?></font>
<TEXTAREA COLS=55 ROWS=16 WRAP="soft" readonly>
<?
$fp = @fopen($comntFile, "r");
if (!$fp)
{
print "Image: " . $imgnam . "\n\n";
}
else
{
$filedata = file($comntFile);
fclose($fp);
for ($n = 0; $n < count($filedata); $n++)
{
printf ("%s\n", trim($filedata[$n]));
}
}
?>
</TEXTAREA>
</th>
</tr>
<tr>
<!-- Display Picture Info -->
<th bgcolor="#fd0000" align="left" width="400" height='190' valign='top'>
<!font color="#FFFF00">
<?
$fp = @fopen($info_File, "r");
if ($fp)
{
$filedata = file($info_File);
fclose($fp);
for ($n = 0; $n < count($filedata); $n++)
{
printf ("%s<br>", trim($filedata[$n]));
}
}
?>
</font>
</th>
<!-- Accept New Comments -->
<th bgcolor="#0000fd" align='center' valign='top'>
<font color="#FFFF00">Add new comments here</font>
<INPUT type="submit" value="Add Comment">
<TEXTAREA COLS=55 ROWS=8 WRAP="soft" NAME="comment"></TEXTAREA>
</th>
</tr>
<tr><td colspan='2' bgcolor='#00D5D5' valign='top'><h3><a name='dir'>Instructions</a></h3><br>
<UL><LI>The Green section picks the specific album to view:</LI>
<OL><LI>Enter your name in the top box if you wish</LI>
<LI>Select an <i>album</i> by using the first dropdown box and click <B>Select Album</B></LI>
<LI>Select an <i>event</i> using the second dropdown box and click <B>Select Album</B> again<br>
(The <i>album</i> must be chosen first so the appropriate events can be loaded)</LI>
<LI>Click on a picture to open it. </LI>
</OL>
<LI>The Red section shows a specific picture with identifying information:</LI>
<OL><LI>View the picture on top, and read the info below it</LI>
<LI>Click on the picture for a larger image</LI>
<LI>If you can add any details to the info, See directions below for blue section</LI>
</OL>
<LI>The Blue section is for additional comments:</LI>
<OL><LI>The top section shows all comments up to the present and can only be viewed</LI>
<LI>The bottom section allows the addition of any stories, new info, corrections, and comments.</LI>
Anything is ok, even if it is a story not about the picture but one that is a memory that is
triggered by the picture.</LI>
<LI>If you have not done so yet, please put in your name at top of green section so the computer
will add your name to your comments</LI>
<LI>Type your comments</LI>
<LI>Click <B>Add Comment</B></LI>
<LI>Your info will be added to the upper box</LI>
</OL>
</UL>
<br>
Questions? Comments? Have more pictures? Please <script language="javascript" type="text/javascript">
<!--
document.write('<a href="');
var by0 = new Array(
-117,-121,-113,-116,-108,-119,-34,-82,-109,-124,
-113,-118,-125,-88,-114,-109,-124,-113,-118,-125,
-54,-123,-119,-117 );
var ix;
var ln = by0.length;
for (ix = 0; ix < ln; ix++)
{ document.write('&');
document.write('#' + (-by0[ix] ^ ln) + ';'); }
document.write('"');
document.write('>email us</a>');
// -->
</script>
</td>
</tr>
</table>
</form>
</body>
</html>
<?
}
?>