Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

$_POST different on form submit methods 1

Status
Not open for further replies.

thedaver

IS-IT--Management
Jul 12, 2001
2,741
US
I used this test code to debug an issue:

Code:
<?php
print_r($_POST);
?>
<form name="test" action=<?php print $_SERVER["PHP_SELF"]; ?> method="POST">
<input type=text name=sometext>
<input type=submit name=submit value=submit>
</form>

If you run it, the $_POST value for "submit" is not set if you press ENTER within the text field.
"submit" IS SET if you TAB onto the submit button and hit ENTER or if you mouse click the "submit" button.

This seems sort of obvious, but I was operating under the assumption that the "submit" event is always present in a submitted form. I NEED to see the "submit" button value in my present form processing code.

Any help much appreciated!!!!!

Surfinbox.com Business Internet Services - National Dialup, DSL, T-1 and more.
 
Er well, ok, I gave a limited example and got a direct answer.... Now let's expand the scope of the issue to where I have 2-3 different submit buttons on the form that help the parsing code determine which field group the user submitted... That's really where the problem comes up.

Fields 1-5 have submit button1,
Fields 2-10 have submit button2,
Fields 11-15 have submit button3.

If a user can hit ENTER on a field, submit the POST of the form and I don't know which submit buttonN was supposed to be recognized, then I'm S.O.L.

Hope that better clarifies the issue. Thanks for your early answer

Surfinbox.com Business Internet Services - National Dialup, DSL, T-1 and more.
 
A value for a submit button is only sent if the submit button is named, and if it has been clicked. Submit the form any other way and you are S.O.L.

Although this is a browser-side issue, I have found that Opera, Netscape, IE, and Mozilla all behave this way.

Want the best answers? Ask the best questions!

TANSTAAFL!!
 
OK sleipnir, I'll concede the broken functionality. However, how do I resolve the issue...

Q: A single form has multiple groups of fields with a submit button for each group. Assuming that each group has at least text input which manifests this problem, how do I determine (using PHP) which group of fields was submitted?

I'm convinced someone has solved this before. I can use Javascript on the page if necessary (sigh....)

Surfinbox.com Business Internet Services - National Dialup, DSL, T-1 and more.
 
Would multiple <form></form> tags solve this? I could parse $_POST for the form name submitted??? Does the submit process work like that so that only the "relevant" form data is posted?? BTW, I understand hidden fields, but I'm struggling with how I'd detect that a hidden field value was the discriminating test between the subform groups.. Maybe an example?

Surfinbox.com Business Internet Services - National Dialup, DSL, T-1 and more.
 
I'm sorry. I was assuming that each group of input fields was in its own set of <form>...</form> tags. That way, you only submit the group of inputs that you're currently working on.

Each input group in its own <form>...</form> tag would have a hidden field named "form_identifier", the value of which uniquely identifies that group.

Want the best answers? Ask the best questions!

TANSTAAFL!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top