Log in

View Full Version : Form Submission Firefox vs. IE



jshaw3
02-21-2008, 11:04 PM
Hi,

I am having problems working with forms and drop down menus being submitted between IE and Firefox.

I am working on dynamic graphs allowing the user to select the number of bars displayed in the graph. All of the information is being stored in a MYSQL database. The graphs are being created with the GD Library. The users select the location (this works) than selects the number of bars to be displayed. ex. 7 bars. I am using GET for the form and passing the variable to the same page. When the form is submitted the graph is drawn and saved to the server. When the form is submitted the page relodes and the newest graph is displayed on the page. This works fine in FF but in IE what i suspect is happining is the browser is not reconixing the passed variable and is not drawing and saving the new graph. I suspect this because in IE when i submit the form it doesn't work, however if i refresh the newly reloaded page the proper graph shows.

Is there a reason why in firefox the variable is awknowledged and creates than displayes the proper graph automatically but not in IE? Is there a way to solve the issue with IE? The code is below.

I know there are still a lot of other bugs but this is my main concern at the moment.



if (!isset($_REQUEST['display'])){

$display = 5;

}elseif(isset($_REQUEST['display'])){

$display = $_REQUEST['display'];

}

$now = time();
date_default_timezone_set('EST5EDT');
$date = strftime('%H_%M_%S_%b%d%y',$now);

if(isset($_COOKIE['city']) && isset($_COOKIE['country'])){

$localCity = $_COOKIE['city'];
$localCountry = $_COOKIE['country'];
}



$loc = $_REQUEST['loc'];
echo $loc;

$allCities = @mysql_query("SELECT DISTINCT city FROM webEmotion GROUP BY city ORDER BY `city` DESC");
$numCities=mysql_numrows($allCities);


if ((!isset($_REQUEST['loc'])) || ($loc ==glob)) {

$totalEmo = @mysql_query("SELECT emotion, count( emotion ) AS num_times FROM webEmotion GROUP BY emotion ORDER BY `num_times` DESC");
$totalNum=mysql_numrows($totalEmo);

$emotionOrdered = @mysql_query("SELECT emotion, count( emotion ) AS num_times FROM webEmotion GROUP BY emotion ORDER BY `num_times` DESC LIMIT 0, $display");
$num=mysql_numrows($emotionOrdered);

}
elseif ($loc == $localCity) {
$totalEmo = @mysql_query("SELECT emotion, count( emotion ) AS num_times FROM webEmotion WHERE city='$localCity' GROUP BY emotion ORDER BY `num_times` DESC");
$totalNum=mysql_numrows($totalEmo);

$emotionOrdered = @mysql_query("SELECT emotion, count( emotion ) AS num_times FROM webEmotion WHERE city='$localCity' GROUP BY emotion ORDER BY `num_times` DESC LIMIT 0, $display");
$num=mysql_numrows($emotionOrdered);
} else{

$totalEmo = @mysql_query("SELECT emotion, count( emotion ) AS num_times FROM webEmotion WHERE city='$loc' GROUP BY emotion ORDER BY `num_times` DESC");
$totalNum=mysql_numrows($totalEmo);

if($display<=$totalNum){
$emotionOrdered = @mysql_query("SELECT emotion, count( emotion ) AS num_times FROM webEmotion WHERE city='$loc' GROUP BY emotion ORDER BY `num_times` DESC LIMIT 0, $display");
$num=mysql_numrows($emotionOrdered);
}else{

$emotionOrdered = @mysql_query("SELECT emotion, count( emotion ) AS num_times FROM webEmotion WHERE city='$loc' GROUP BY emotion ORDER BY `num_times` DESC LIMIT 0, $totalNum");
$num=mysql_numrows($emotionOrdered);

}
}

echo "<br /> $display <br />";
$i=0;
while($i<$display){
$emotion_[$i] = mysql_result($emotionOrdered, $i, 'emotion');
$num_test_[$i] = mysql_result($emotionOrdered, $i, 'num_times');

$num_test_[$i] = 500-(($num_test_[$i]/$totalNum)*500);

$i++;
}

$image = ImageCreate(500, 500);
$background_color = ImageColorAllocate($image, 255, 255, 255); //white
$pink = ImageColorAllocate($image, 255, 51, 204); //pink

// blue text
$textcolor = imagecolorallocate($image, 0, 0, 0);

$j = 0;
$barSpace = 10;
while ($j<$display){

$barWidth = (500-($display*10))/$display;

ImageFilledRectangle($image, $barSpace, $num_test_[$j], $barSpace+$barWidth, 500, $pink);
imagestring($image, 5, $barSpace, 480, $emotion_[$j], $textcolor);
$barSpace += ($barWidth+10);

$j++;
}


$url_1 = "image/$loc_$date.png";
$url_2 = "image/image_Graph.png";

ImagePNG($image, $url_1);
ImagePNG($image, $url_2);

?>
<form id="****" name="****" method="get" action="draw.php">
<label>location
<select name="loc" id="loc">
<option value="<? echo $loc; ?>"><? echo $loc; ?></option>
<option value="<? echo $localCity; ?>"><? echo $localCity; ?></option>
<option value="glob">Global</option>
<?
$c=1;
while ($c < $numCities) {

$listCities=mysql_result($allCities,$c,'city');

echo "$emoD: $num_times<br>";
?>
<option value="<? echo $listCities;?>"><? echo $listCities;?></option>
<?
$c++;
}
?>
</select>
</label>
<label>display
<select name="display" id="display">

<?
$d=0;
while ($d < $totalNum) {

$listCities=mysql_result($totalEmo,$d,'city');

?>
<option value="<? echo $d;?>"><? echo $d;?></option>
<?
$d++;
}
?>

</select>
</label>

<input type="submit" id="submit" value="Submit" />

</form>

<img src="image/image_Graph.png" />



Thank you in advanced for the help.

alexjewell
02-22-2008, 12:27 AM
I've never heard of this happening, but it sounds like some sort of html problem and not server-side in nature. The one thing that caught my eye:



<form id="****" name="****" method="get" action="draw.php">


The asterisks? Can you explain why you used them instead of actual letters?

jshaw3
02-22-2008, 12:34 AM
I ment to switch that, its a swear word i used for naming the table one night while getting medium frusterated...

alexjewell
02-22-2008, 12:36 AM
Haha, ok, I'm following you.

Can you link me to where this is happening? I think seeing the source sent to the browser will help me better find the problem.

jshaw3
02-22-2008, 12:44 AM
yep, its hosted here.

http://emocapsule.com/DrawImages/draw.php

I was playing around with the order of the code thinking it had to do with the differences between ff and ie but, still no luck.

Thanks for the help. It's much appreciated.

alexjewell
02-22-2008, 12:47 AM
Well, you may want to make sure the site follows standards first. Your DOCTYPE says XHTML, but your tags don't follow XHTML standards. IE is touchy with that stuff sometimes. The other thing I don't understand, although I'm sure it has a purpose, is:



<meta name="verify-v1" content="c9zyRbx8dNJrxLqc/GyGfaD4pdQZOwUW9gGvoA1wSSE=" />


It's most likely not affecting anything, but I'm just curious what it's purpose is?

jshaw3
02-22-2008, 06:29 PM
Alexjewell, thanks for all of your help. It turned out to be IE cashing issue.... gah

alexjewell
02-25-2008, 12:39 AM
As always. :p

Best of luck.