IE vs Firefox fourm submit issues

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
trent2800
Forum Commoner
Posts: 48
Joined: Mon Oct 02, 2006 7:02 am

IE vs Firefox fourm submit issues

Post by trent2800 »

This seems to be a strange error, when I click submit in IE, nothing. But, when I use the same page in Firefox, the form submits and everything seems fine.


Here's the code:

Code: Select all

<?PHP

$action = $_GET['action'];
$mode = $_GET['mode'];
$ProductID = $_GET['ProductID'];


$dbh=mysql_connect ("localhost", "******", "*******") or die ('I cannot connect to the database because: ' . mysql_error());

mysql_select_db ('db');

$query = "SELECT * FROM CLOTHING WHERE ProductID = '" . $ProductID . "'";

$result = mysql_query($query) or die('Query failed: ' . mysql_error());

if (!$result) {
   $message  = 'Invalid query: ' . mysql_error() . "\n";
   $message .= 'Whole query: ' . $query;
   die($message);
}

$row = mysql_fetch_assoc($result);

$query = "SELECT * FROM ARTISTS ORDER BY ArtistID ASC";

$result2 = mysql_query($query) or die('Query failed: ' . mysql_error());

echo "<h1>Edit Item</h1>\n";

echo "<table align=center width=100%>\n";

echo "<form enctype=\"multipart/form-data\" action=\"index.php?mode=clothing&action=upload\" method=\"POST\">\n";

echo "<input type=\"hidden\" name=\"MAX_FILE_SIZE\" value=\"300000\" />\n";

echo "<input type=\"hidden\" name=\"ProductID\" value=\"".$ProductID."\" />\n";

echo "<tr align=left><td width=\"105\">Name: </td><td width=\"272\"><input value=\"" . $row['Name'] . "\"name=\"Name\" type=\"text\" maxlength=\"45\" size=\"45\" /></td></tr>\n";

echo "<tr align=left><td>Price: </td><td><input value=\"" . $row['Price'] . "\" name=\"Price\" type=\"text\" /></td></tr>\n";

echo "<tr align=left><td>Sold: </td><td><select name=\"Sold\">\n";

switch ($row['Sold']) {
	case "0":
		echo "<option value=\"1\">Yes</option>\n<option value=\"0\" SELECTED>No</option>\n</select>\n";
		break;
	case "1":
		echo "<option value=\"1\" SELECTED>Yes</option>\n<option value=\"0\">No</option>\n</select>\n";
		break;
}
echo "<tr align=left><td>Artist: </td><td><select name=\"ArtistID\">\n";

while ($row2 = mysql_fetch_assoc($result2)) {
$message = "<option value=\"".$row2['ArtistID']."\"";
if ($row['ArtistID'] == $row2['ArtistID']) { $message = $message . " SELECTED >"; }else{$message = $message . ">";}
$message = $message . $row2['FirstName'] . " " . $row2['LastName'] . "</option>\n";
echo $message;
}

echo "</select>\n";
echo "</td></tr>";
echo "<td><tr>";

mysql_free_result($result2);

$query = "SELECT * FROM CATEGORY WHERE Parent = '1' ORDER BY CategoryID ASC";

$result3 = mysql_query($query) or die('Query failed: ' . mysql_error());

echo "<tr align=left><td>Category: </td><td><select name=\"CategoryID\">\n";

while ($row3 = mysql_fetch_assoc($result3)) {
$message = "<option value=\"" . $row3['CategoryID'] ."\"";
if ($row['CategoryID'] == $row3['CategoryID']) { $message = $message . " SELECTED >"; }else{$message = $message . ">";}
$message = $message . $row3['Name'] . "</option>\n";
echo $message;
}
echo "</select>\n";

mysql_free_result($result3);

echo "<tr align=left><td>Description: </td><td><textarea rows=10 cols=60 name=\"Desc\" rows=\"4\" >" . $row['Desc'] . "</textarea></td></tr>\n";
echo "</td></tr>\n";
echo "<tr align=left><td colspan=\"2\"><h2><b>Measurements</b></h2></td></tr>\n";
echo "<tr align=left><td colspan=\"2\"><em>Note: Enter in only the measurements that are pertinant.</em></td></tr>\n";
echo "<tr align=left><td>Bodice: </td><td><input value='" . $row['Bodice'] . "' name=\"Bodice\" maxlength=\"20\" type=\"text\" /></td></tr>\n";
echo "<tr align=left><td>Spin: </td><td><input value='" . $row['Spin'] . "' name=\"Spin\" maxlength=\"20\" type=\"text\" /></td></tr>\n";
echo "<tr align=left><td>Length: </td><td><input value='" . $row['Length'] . "' name=\"Length\" maxlength=\"20\" type=\"text\" /></td></tr>\n";
echo "<tr align=left><td>Waist: </td><td><input value='" . $row['Waist'] . "' name=\"Waist\" maxlength=\"20\" type=\"text\" /></td></tr>\n";
echo "<tr align=left><td>Inseam: </td><td><input value='" . $row['Inseam'] . "' name=\"Inseam\" maxlength=\"20\" type=\"text\" /></td></tr>\n";
echo "<tr align=left><td>Chest: </td><td><input value='" . $row['Chest'] . "' name=\"Chest\" maxlength=\"20\" type=\"text\" /></td></tr>\n";

echo "<tr align=left><td colspan=\"2\"><h2><b>Images</b></h2><br /><em>Only use browse if you want to change the current picture.</em></td></tr>\n";

echo "<tr><td colspan=100%><table cellspacing=0 cellpadding=0 border=1 bordercolor=red width=800>\n";

echo "<tr align=center><td>\n";
echo "<strong>Front:</strong><br />\n";
	if (file_exists("/home/guttersg/www/images/clothing/" . $row['ProductID'] . "_front.jpg")) {
		echo "<img name=prodimg" . $row['ProductID'] . " width=300px height=400px src=/images/clothing/" . $row['ProductID'] . "_front.jpg>\n";
	}else{
		echo "<img name=prodimg" . $row['ProductID'] . " width=300px height=400px src=/images/noimg.jpg>\n";
	}
echo "<br /><input name=\"front\" type=\"file\" />\n";
echo "</td>\n";
		
echo "<td>\n";
echo "<strong>Back:</strong><br />\n";
	if (file_exists("/home/guttersg/www/images/clothing/" . $row['ProductID'] . "_back.jpg")) {
		echo "<img name=prodimg" . $row['ProductID'] . " width=300px height=400px src=/images/clothing/" . $row['ProductID'] . "_back.jpg>\n";
	}else{
		echo "<img name=prodimg" . $row['ProductID'] . " width=300px height=400px src=/images/noimg.jpg>\n";
	}
echo "<br /><input name=\"back\" type=\"file\" />\n";
echo "</td></tr>\n";

echo "<tr align=center><td>\n";
echo "<strong>Detail 1:</strong><br />\n";
	if (file_exists("/home/guttersg/www/images/clothing/" . $row['ProductID'] . "_detail1.jpg")) {
		echo "<img name=prodimg" . $row['ProductID'] . " width=300px height=400px src=/images/clothing/" . $row['ProductID'] . "_detail1.jpg>\n";
	}else{
		echo "<img name=prodimg" . $row['ProductID'] . " width=300px height=400px src=/images/noimg.jpg>\n";
	}
echo "<br /><input name=\"detail1\" type=\"file\" />\n";
echo "</td>\n";

echo "<td>\n";
echo "<strong>Detail 2:</strong><br />\n";
	if (file_exists("/home/guttersg/www/images/clothing/" . $row['ProductID'] . "_detail2.jpg")) {
		echo "<img name=prodimg" . $row['ProductID'] . " width=300px height=400px src=/images/clothing/" . $row['ProductID'] . "_detail2.jpg>\n";
	}else{
		echo "<img name=prodimg" . $row['ProductID'] . " width=300px height=400px src=/images/noimg.jpg>\n";
	}
echo "<br /><input name=\"detail2\" type=\"file\" />\n";
echo "</td></tr>\n";

echo "</table></td></tr>\n";

echo "<tr align=left><td colspan=\"2\" align=\"left\"><br /><br /><input type=\"submit\" value=\"Submit\" onClick=\"this.disabled=true; this.value='Please Wait...';\"/> <input type=reset> <input type=button value=Cancel onClick=\"window.location='index.php?mode=clothing'\"></td></tr>\n";


echo "</form>\n";
echo "</table>\n";

mysql_free_result($result);
mysql_close($dbh);
?>
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Post by Christopher »

It is difficult to see what the problem with the HTML could be with all the PHP there. Can you post the actual HTML generated?
(#10850)
trent2800
Forum Commoner
Posts: 48
Joined: Mon Oct 02, 2006 7:02 am

Post by trent2800 »

Done:

Code: Select all

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html>

<head>

<title>Gutter's Goods Administration Page</title>

<style type="text/css" media="all">


	@import url(adminstyle.css);

</style>

</head>
<body>
<table border="1" bordercolor="black" width="50%" align="center" cellspacing="0" cellpadding="2">
<td align="center"><a href=index.php?mode=clothing>Clothing</a></td>

<td align="center"><a href=index.php?mode=incense>Incense</a></td>
<td align="center"><a href=index.php?mode=showdates>Show Dates</a></td>
<td align="center"><a href=index.php?mode=artists>Artists</a></td>
<td align="center"><a href=index.php?mode=links>Links</a></td>
</table>
<center>
<h1>Edit Item</h1>
<table align=center width=100%>
<form enctype="multipart/form-data" action="index.php?mode=clothing&action=upload" method="POST">
<input type="hidden" name="MAX_FILE_SIZE" value="300000" />
<input type="hidden" name="ProductID" value="3" />
<tr align=left><td width="105">Name: </td><td width="272"><input value="Test Hoodie1"name="Name" type="text" maxlength="45" size="45" /></td></tr>

<tr align=left><td>Price: </td><td><input value="34.00" name="Price" type="text" /></td></tr>
<tr align=left><td>Sold: </td><td><select name="Sold">
<option value="1">Yes</option>
<option value="0" SELECTED>No</option>
</select>
<tr align=left><td>Artist: </td><td><select name="ArtistID">
<option value="1">Birdy </option>
<option value="2" SELECTED >Bob Dole</option>
</select>
</td></tr><td><tr><tr align=left><td>Category: </td><td><select name="CategoryID">

<option value="2">Dresses</option>
<option value="3">Skirts</option>
<option value="4" SELECTED >Hoodies</option>
<option value="5">Pants/Shorts</option>
<option value="6">Tops</option>
<option value="7">Accessories</option>
</select>
<tr align=left><td>Description: </td><td><textarea rows=10 cols=60 name="Desc" rows="4" >This is a test hoodie, for testing.</textarea></td></tr>
</td></tr>

<tr align=left><td colspan="2"><h2><b>Measurements</b></h2></td></tr>
<tr align=left><td colspan="2"><em>Note: Enter in only the measurements that are pertinant.</em></td></tr>
<tr align=left><td>Bodice: </td><td><input value='1' name="Bodice" maxlength="20" type="text" /></td></tr>
<tr align=left><td>Spin: </td><td><input value='1' name="Spin" maxlength="20" type="text" /></td></tr>
<tr align=left><td>Length: </td><td><input value='1' name="Length" maxlength="20" type="text" /></td></tr>
<tr align=left><td>Waist: </td><td><input value='1' name="Waist" maxlength="20" type="text" /></td></tr>
<tr align=left><td>Inseam: </td><td><input value='1' name="Inseam" maxlength="20" type="text" /></td></tr>
<tr align=left><td>Chest: </td><td><input value='1' name="Chest" maxlength="20" type="text" /></td></tr>
<tr align=left><td colspan="2"><h2><b>Images</b></h2><br /><em>Only use browse if you want to change the current picture.</em></td></tr>

<tr><td colspan=100%><table cellspacing=0 cellpadding=0 border=1 bordercolor=red width=800>
<tr align=center><td>
<strong>Front:</strong><br />
<img name=prodimg3 width=300px height=400px src=/images/noimg.jpg>
<br /><input name="front" type="file" />
</td>
<td>
<strong>Back:</strong><br />
<img name=prodimg3 width=300px height=400px src=/images/noimg.jpg>
<br /><input name="back" type="file" />
</td></tr>
<tr align=center><td>
<strong>Detail 1:</strong><br />
<img name=prodimg3 width=300px height=400px src=/images/noimg.jpg>

<br /><input name="detail1" type="file" />
</td>
<td>
<strong>Detail 2:</strong><br />
<img name=prodimg3 width=300px height=400px src=/images/noimg.jpg>
<br /><input name="detail2" type="file" />
</td></tr>
</table></td></tr>
<tr align=left>
<td colspan="2" align="left"><br /><br />

<input type="submit" value="Submit" onClick="this.disabled=true; this.value='Please Wait...';"/> 
<input type=reset> 
<input type=button value=Cancel onClick="window.location='index.php?mode=clothing'"></td></tr>

</form>
</table>
</center>
</body>
</head>

</html>
User avatar
churt
Forum Commoner
Posts: 39
Joined: Wed Oct 04, 2006 9:59 am

Appears to be a quirk of IE but this seems to work

Post by churt »

I changed it to a button and let onClick do the submit. Hope this helps.


<input type=\"button\" value=\"Submit\" onClick=\" this.value='Please Wait...'; this.disabled=true; this.form.submit()\">
trent2800
Forum Commoner
Posts: 48
Joined: Mon Oct 02, 2006 7:02 am

Post by trent2800 »

Now everything works fine for my upload script in firefox but IE returns this:

Warning: imagejpeg(): supplied argument is not a valid Image resource in /home/guttersg/public_html/admin/includes/upload.php on line 31

Warning: imagesx(): supplied argument is not a valid Image resource in /home/guttersg/public_html/admin/includes/upload.php on line 37

Warning: imagesy(): supplied argument is not a valid Image resource in /home/guttersg/public_html/admin/includes/upload.php on line 37

Warning: imagesx(): supplied argument is not a valid Image resource in /home/guttersg/public_html/admin/includes/upload.php on line 46

Warning: imagesy(): supplied argument is not a valid Image resource in /home/guttersg/public_html/admin/includes/upload.php on line 47

Warning: imagecreatetruecolor() [function.imagecreatetruecolor]: Invalid image dimensions in /home/guttersg/public_html/admin/includes/upload.php on line 50

Warning: imagesx(): supplied argument is not a valid Image resource in /home/guttersg/public_html/admin/includes/upload.php on line 52

Warning: imagesy(): supplied argument is not a valid Image resource in /home/guttersg/public_html/admin/includes/upload.php on line 52


Warning: imagecopyresampled(): supplied argument is not a valid Image resource in /home/guttersg/public_html/admin/includes/upload.php on line 52

Warning: imagejpeg(): supplied argument is not a valid Image resource in /home/guttersg/public_html/admin/includes/upload.php on line 54

From this script:

Code: Select all

function upload_image($view, $ProductID, $category, $th){
			$filename = $_FILES[$view]['name'];
			$temporary_name = $_FILES[$view]['tmp_name'];
			$mimetype = $_FILES[$view]['type'];
			$filesize = $_FILES[$view]['size'];
			$errors = '';

			switch($mimetype) {
				case "image/bmp":
					$i = imagecreatefromwbmp($temporary_name);
			    case "image/jpg":
			    case "image/jpeg":
					$i = imagecreatefromjpeg($temporary_name);
					break;
				case "image/gif":
					$i = imagecreatefromgif($temporary_name);
					break;
				case "image/png":
					$i = imagecreatefrompng($temporary_name);
					break;
			}
			
			unlink($temporary_name);

				
			imagejpeg($i,"/home/guttersg/www/images/".$category."/".$ProductID."_".$view.".jpg",80);
			if ($view = 'front') {
				if ($th) {
					$dest_x = 150;
					$dest_y = 150;
					
					if (imagesx($i) > $dest_x or imagesy($i) > $dest_y) {
						if (imagesx($i) >= imagesy($i)) {
							$thumb_x = $dest_x;
							$thumb_y = imagesy($i)*($dest_x/imagesx($i));
						} else {
							$thumb_x = imagesx($i)*($dest_y/imagesy($i));
							$thumb_y = $dest_y;
						}
					} else {
						$thumb_x = imagesx($i);
						$thumb_y = imagesy($i);
					}
					
					$thumb = imagecreatetruecolor($thumb_x,$thumb_y);
					
					imagecopyresampled($thumb, $i ,0, 0, 0, 0, $thumb_x, $thumb_y, imagesx($i), imagesy($i));
					
					imagejpeg($thumb, "/home/guttersg/www/images/".$category."/th_".$ProductID.".jpg", 80);
				}
			}
		}
trent2800
Forum Commoner
Posts: 48
Joined: Mon Oct 02, 2006 7:02 am

Post by trent2800 »

OMFG, can I give microsoft a hug?! They decided to have their OWN MIME TYPE! image/pjpeg? THATS AWESOME! :evil: :evil:


Better code:

Code: Select all

switch($mimetype) {
			
				case "image/bmp":
					echo "<h2>No BMP files, convert them to jpg/png/gif.</h2>\n";
					return;
			    case "image/jpg":
			    case "image/jpeg":
					$i = imagecreatefromjpeg($temporary_name);
					break;
				case "image/pjpeg";
					$i = imagecreatefromjpeg($temporary_name);
					break;
				case "image/gif":
					$i = imagecreatefromgif($temporary_name);
					break;
				case "image/png":
					$i = imagecreatefrompng($temporary_name);
					break;
				default:
					echo "Unrecognised file type!  Try again with a jpg, png or gif file!\n";
					break;
					
			}
User avatar
churt
Forum Commoner
Posts: 39
Joined: Wed Oct 04, 2006 9:59 am

They are grand about that kind of thing.

Post by churt »

All depends on how hard you hug :twisted:.

I manage a number of corporate firewalls and the number of different content types for excel and word are just silly. Seriously, they need to get some standards for this kind of thing.

Later,
C
Post Reply