dcsimg
www.webdeveloper.com
Results 1 to 6 of 6

Thread: Form names..

  1. #1
    Join Date
    May 2004
    Posts
    442

    Form names..

    OK I am new to PHP and just modifying some existing code at the moment. ( simple stuff!).
    I have some php that generates some pages accessed through a system of forms. Depending what you submit in one form dictates what is displayed on the next.
    The problem is that the existing code is a bit of a mess becuase it doesn't differentiate between the forms. It does all of it's processing on the names of the fields. Opps. I assume that it is possible to determine which form the data has some from, given that I can assign a name to each form. But in PHP how do I access/discover the name of the form that sent the data?
    Last edited by SuzanneB; 03-20-2005 at 07:13 AM.

  2. #2
    Join Date
    Dec 2004
    Posts
    8,637
    Nope, sorry, the HTML FORM name is not transmitted to the server. If you want it to be, you must place that name into the value of a hidden field (don't even name a field with the same name as the FORM -- unless there is no client-side scripting going on at all). Thus, that code is correct in that it references everything by field name.

  3. #3
    Join Date
    May 2004
    Posts
    442
    Oh, OK, that's what I already did. I was thinking there might be a better way though!! You see in the existing code, the author went to the trouble of naming all the forms, and I was wondering why. Clearly he was just completely insane. :-)

  4. #4
    Join Date
    Dec 2004
    Posts
    8,637
    Well, that depends (I guess) on whether there is any JavaScript (or other client-side script) that needs to work with the form. In this case, having a name for the form is a good idea.

  5. #5
    Join Date
    May 2004
    Posts
    442
    Hi!
    No there wasn't. The processing was entirely server side.

  6. #6
    Join Date
    Dec 2004
    Posts
    8,637
    OK, then let's just say he was a creature of habit.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles