Jump to content

PHP code not working in IE, while working in firefox


ashvini

Recommended Posts

I am using following php code:<?php// Gets data from URL parameters$name = $_GET ['name'];$address = $_GET['address'];$select_product = $_GET['select_product'];$quantity = $_GET['quantity'];$battery_code = $_GET['battery_code'];$contact_number=$_GET['contact_number'];// Opens a connection to a MySQL server$connect = mysql_connect ("localhost", "root") or die ("Could not connect to server :" . mysql_error());// Set the active MySQL database$db = mysql_select_db("genset", $connect) or die ("Could not select db :" . mysql_error());// Insert new row with user data$query ="insert into request (name, address, select_product, quantity, battery_code, contact_number, total_amount) values ('$name', '$address', '$select_product', '$quantity', '$battery_code', '$contact_number','0')";mysql_query($query) or die ("Could not insert new data :" . mysql_error());mysql_free_result($result);header( 'Location: http://localhost/order.html' ) ;?>This works great in firefox (i.e. values are getting save once click on submit button on form), but this is not working once I submit form from IE, blank values get inserted in DB when submitting form through IE.Please suggest.PS** I am using IE8

Link to comment
Share on other sites

I'll leave the mysql_real_escape_string() omission for now, but... what does the form look like? It could be a factor. Do you explicitly specify the "get" method on it?

Link to comment
Share on other sites

I'll leave the mysql_real_escape_string() omission for now, but... what does the form look like? It could be a factor. Do you explicitly specify the "get" method on it?
No, I didn't specify "get" method.Here is the Form tag:<form name="home_form" action="http://localhost/phpsqlinfo_addrow.php" enctype="text/plain" id="home_form" onsubmit="return Validatehome_form(this)">Here is the calling part:<input id="Button1" name="submit" value="Place Order" style="position: absolute; left: 378px; top: 472px; width: 140px; height: 24px; z-index: 26;" type="submit">
Link to comment
Share on other sites

Different browsers get uptight about different rules. The rules say you must specify a method. So method="get" -- put that in your form tag. See what happens. After reading boen's question, I'm surprised you have not already tried this.

Link to comment
Share on other sites

Different browsers get uptight about different rules. The rules say you must specify a method. So method="get" -- put that in your form tag. See what happens. After reading boen's question, I'm surprised you have not already tried this.
Used method get but no effect:<form name="home_form" action="http://localhost/phpsqlinfo_addrow.php" enctype="text/plain" id="home_form" method="get" onsubmit="return Validatehome_form(this)">Please suggest.
Link to comment
Share on other sites

If there is a difference, it is probably not in the PHP code, but in the HTML or the JavaScript. You have shown us only a small portion of those, not enough to make suggestions.
Wired, you know programming better than me... I don't know single bit of programming (whatever I did is copy-paste from Google), I am just product management guy... even though I have few facts.... and ..I Disagree.... with you...How come its possible that its working fine on Firefox and not IE, html is calling php code and passing parameters correctly on both IE and FF.and Firefox handle those gracefully while IE is not. And JS is out of the picture.Moreover, while execute php code stand alone (i.e. without passing through html code) FF execute php code without any issue, while IE showing below errors:Notice: Undefined index: name in C:\wamp\www\phpsqlinfo_addrow.php on line 4Notice: Undefined index: address in C:\wamp\www\phpsqlinfo_addrow.php on line 5Notice: Undefined index: select_product in C:\wamp\www\phpsqlinfo_addrow.php on line 6Notice: Undefined index: quantity in C:\wamp\www\phpsqlinfo_addrow.php on line 7Notice: Undefined index: battery_code in C:\wamp\www\phpsqlinfo_addrow.php on line 8Notice: Undefined index: contact_number in C:\wamp\www\phpsqlinfo_addrow.php on line 9So I can rule out the fact that its not HTML code issue, its IE.I am using IE 8, I am not sure but lets try with IE6 or IE7.
Link to comment
Share on other sites

those errors are telling you something is wrong with the page in general. One browser just happens to be handling it better than the other. Time to go through the page and fix whatever's causing those errors, and then you should see better stability amongst all browsers.

Link to comment
Share on other sites

You must understand this: a browser does not execute PHP code. A browser sends data to your server (local server or remote server) and the server executes the PHP. In your case, I assume the same server executes the PHP no matter which browser you are using. This means the difference is in the way your browser is processing the data before it sends it to the server.Be aware that some of the biggest differences between IE and the other browsers is in the way it runs JavaScript. I suspect some of your problem is in your Validatehome_form function. It may even be a very simple difference. There may also be a difference in the way your HTML is structured that causes your JavaScript to execute differently.Since this is a GET operation, you should be able to look at the query string and see exactly what the browsers are sending to the server.I don't know why you would not want to post more code. It can only help.

Link to comment
Share on other sites

You must understand this: a browser does not execute PHP code. A browser sends data to your server (local server or remote server) and the server executes the PHP. In your case, I assume the same server executes the PHP no matter which browser you are using. This means the difference is in the way your browser is processing the data before it sends it to the server.Be aware that some of the biggest differences between IE and the other browsers is in the way it runs JavaScript. I suspect some of your problem is in your Validatehome_form function. It may even be a very simple difference. There may also be a difference in the way your HTML is structured that causes your JavaScript to execute differently.Since this is a GET operation, you should be able to look at the query string and see exactly what the browsers are sending to the server.I don't know why you would not want to post more code. It can only help.
Hmm... make sense.let me play around with JS stuff.
Link to comment
Share on other sites

Hmm... make sense.let me play around with JS stuff.
Hi All, Finally I got the solution :)In form tag, enctype="text/plain" was causing the issue.I just got some php code on Google that was working fine (i.e. saving value in DB through IE).So I just started copy paste my code in that file tag wise and finally got culprit 'form' tag. Took so much time (:Thanks all of you, for giving your time in this thread and helping me during this issue.This is really nice forum with nice people.Have a great day...
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...