forms - How can PHP determine if user pressed Enter key or Submit button? -


The problem I'm having is that I have multiple forms submitted in the same form. Each has a different value and I like to keep them in the form of deposits.

Whenever the user enters the press, it seems that the highest input input is being pressed, and therefore it is causing problems to check the code for the input which was clicked on the input.

Is there a way for PHP to determine whether the input is clicked on, or was it selected only when the user pressed the Enter key?

You can identify which button you used, and & lt ; Input type = "submit" name = "verb" value = "edit" & gt; & Lt; Input type = "submit" name = "action" value = "preview" & gt; & Lt; Input type = "submit" name = "verb" value = "post" & gt; There will be significant "action" with the value passed in

$ _ POST array (or $ _GET / $ _ requests ) Button (whether clicked or not)

Now, "clicking" is clearly a client-side behavior - if you want to differentiate between a click and a keypad, then you need some scripting to help in your determination Form.

Edit

Alternatively, you can "sneak" and use a secret submission, which would be the true identity of pressing a key to present Should, but it probably has some significant impact on reach.

  & lt ;? Php if ('POST' == $ _SERVER ['REQUEST_METHOD']) {echo '& lt; Pre & gt; '; Print_r ($ _POST); Echo & lt; / Pre & gt; '; }? & Gt; & Lt; Form method = "post" & gt; & Lt; Input type = "text" name = "test" value = "hello world" & gt; & Lt; Input type = "submit" name = "action" value = "none" style = "display: none" & gt; & Lt; Input type = "submit" name = "verb" value = "edit" & gt; & Lt; Input type = "submit" name = "action" value = "preview" & gt; & Lt; Input type = "submit" name = "verb" value = "post" & gt; & Lt; / Form & gt;  

Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -