Forum Moderators: coopster

Message Too Old, No Replies

PHP Form Error

Not recognizing $_POST['submit']

         

wfernley

7:55 pm on Nov 24, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi I have a simple form in HTML and PHP. For some reason when submitting the form, $_POST['submit'] will only be recognized when pressing the submit button and not when a person presses the enter button after entering text in an input field. Does anyone know why? It works in Netscape and FireFox just not IE.

Any ideas? Do I have to use a Javascript to make this happen? I dont remember having problems before doing this.

Thanks :)

Wes

Birdman

10:29 pm on Nov 24, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Did you give the submit input a name or id attribute?

Robber

9:12 am on Nov 25, 2004 (gmt 0)

10+ Year Member



This is quite an old problem, makes it a problem if you are testing whether $_POST['submit'] exists before your script decides whether or not to do some processing.

When I came across this I changed from using:
if($_POST['submit']){
// do some processing
}

to

if(!empty($_POST)){
// do some processing
}

wfernley

1:50 pm on Nov 25, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thanks for the replies :)

I don't give it an ID but I do give it a name. Should I be giving it an ID?

I wouldn't be able to use if(!empty($_POST)){ because I have more than one form on the page. Now what the form is for is a search so they can find FAQ's on my products. What I did to fix the situation though is see if the actual input field isset(). This seems to be working fine and works in all browsers I have tested it in.

Would this be a good fix or could it pose problems? It was either that or figure out some javascript to do it, which I really didn't want to get into.

Thanks again :)

Wes