General Question

klaas4's avatar

Form does work in Firefox/Opera/Safari, but not in IE?

Asked by klaas4 (2194points) May 11th, 2008

Stupid IE!! I made this search-form which I’m happy with, but it doesn’t work in IE. It submits, but it’s not processed.

Why? What’s wrong with it? Nothing, right? Another IE bug thing?

It doesn’t work in IE6, IE7, and IE8 beta. :@

See it in action here. Temporarily granted all access.

Observing members: 0 Composing members: 0

6 Answers

xyzzy's avatar

for starters, use $_REQUEST instead of $_POST and $_GET. $_REQUEST combines the two so that you don’t have to duplicate your php code like that.

second, you have a nasty sql injection vulnerability there. NEVER EVER EVER construct sql like that. Learn to use placeholders, or better yet use an database abstraction like like Pear::DB or Adodb.

As to the form problem, I’m not sure. Put a “print_r($_REQUEST)” at the top to see exactly what IE is passing to the server.

klaas4's avatar

Oh yeah, I see, forgot to use mysql_real_escape_string there.
I know of it.

I’ll try echoing it, but I’m not going to use $_REQUEST. I have more variables with the same name. ($_GET[‘id’] & $_POST[‘id’]) That will confuse PHP.

jasonjackson's avatar

Ah.. yeah, I’ve run into this before too.

It’s because when you hit the enter/return key to submit a form in IE, it doesn’t send the name/value of the submit button with the form, but the other browsers do. You’re deciding whether to run the search based on the submit button, so that search code doesn’t get triggered by IE if enter/return is used to submit the form. (If you click the “Zoek” button instead, the search works in IE as well as other browsers.)

To make it work in all browsers (including IE), change this line:

if(isset($_POST[‘search’])) {

to something like this:

if (!empty($_POST[‘searchstring’])) {

That oughta do it. :)

klaas4's avatar

Thanks, I will try it.

klaas4's avatar

Works like a charm, thanks!

jasonjackson's avatar

Glad to help. :)

Answer this question

Login

or

Join

to answer.

This question is in the General Section. Responses must be helpful and on-topic.

Your answer will be saved while you login or join.

Have a question? Ask Fluther!

What do you know more about?
or
Knowledge Networking @ Fluther