Accessing the form name

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dwilliamsvancouv
    New Member
    • Oct 2006
    • 1

    Accessing the form name

    I am using PHP to process form data from a web page. How can I access the name of the form that was used to submit the form data? It does not seem to be available in the $_POST array.
  • raji20
    New Member
    • Aug 2006
    • 28

    #2
    The name of the form is not passed with the form collection. So, if you have multiple forms pointing to the same page, you can do one of several things:

    1. Include the name of the form in a hidden input field within each form.

    2. Use different submit buttons, and check for the presence of each in the target page.

    3. Use a hidden element in each form that will go to the same page, this way you can determine the form that was submitted. This should be sufficient, unless you don't have control over the submitting forms. If you don't, you have to explain to the people who DO have control over them, that you need some way to distinguish their requests.

    4. If your forms come from different pages, use HTTP_REFERER to determine what page the request came from.

    Comment

    • ronverdonk
      Recognized Expert Specialist
      • Jul 2006
      • 4259

      #3
      Be aware that some ISP's do not allow and do not set the HTTP_REFERER, so it could be blank. Best is to pass it as a hidden field in the form.

      Ronald :cool:

      Comment

      Working...