Reputation: 81
I was wondering if there is anyway to count the number of forms on a page using any php function, for example using get file contents.
What i would like to find is the sequence number of the form that has been submitted. Like for example, if the second form out of say 5 forms on the page has been submitted using POST
Upvotes: 1
Views: 282
Reputation: 3617
If you really want to count the number of forms using PHP then yes there is a method in which you can load the DOM in php and count the number of form tags from this link domdocument in php specifically at this example how to get tags by name
But a better method at getting sequence would be to add
<input type = "hidden" name = "sequence" value = x>
where "x" above in the code represents the form number that has been posted. The form number is contained in the variable $_POST["sequence"]
Upvotes: 3