SitePoint Sponsor

User Tag List

Results 1 to 13 of 13
  1. #1
    SitePoint Member
    Join Date
    Jun 2005
    Posts
    20
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Form Name in XHTML 1.1

    Anybody know how to identify forms in XHTML 1.1? The name attribute on a form tag throws an error in the W3C validator, but I am using the name attribute to identify the form for processing on the same PHP page:

    PHP Code:
    if (isset($_POST['form_name'])) { 
    What is the correct way to do this in XHTML 1.1?

  2. #2
    SitePoint Member
    Join Date
    Jun 2005
    Posts
    20
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Actually, it's the same in XHTML 1.0 Strict, so it's not something new in 1.1.

  3. #3
    bronze trophy
    Join Date
    Dec 2004
    Location
    Sweden
    Posts
    2,670
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Use a hidden input field.
    Simon Pieters

  4. #4
    Non-Member deathshadow's Avatar
    Join Date
    Jul 2006
    Location
    Dublin, NH
    Posts
    901
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Heh, and this is where the comedy ensues - as it appears people didn't understand the question - either that or I'm just reading it differently.

    The answer he's looking for is that there is no name attribute in XHTML, you use ID instead... so if you had:

    <form name="form_name"> in your HTML, it's
    <form id="form_name"> in XHTML

    Took me a while when I was asking about the same thing a year ago, as nobody seemed to understand what it was I was asking.

  5. #5
    In memoriam gold trophysilver trophybronze trophy Dan Schulz's Avatar
    Join Date
    May 2006
    Location
    Aurora, Illinois
    Posts
    15,478
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You know deathshadow, I could have just told you to use ID instead of name .

  6. #6
    Non-Member deathshadow's Avatar
    Join Date
    Jul 2006
    Location
    Dublin, NH
    Posts
    901
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Dan Schulz View Post
    You know deathshadow, I could have just told you to use ID instead of name .
    I think you were the one that DID.

  7. #7
    In memoriam gold trophysilver trophybronze trophy Dan Schulz's Avatar
    Join Date
    May 2006
    Location
    Aurora, Illinois
    Posts
    15,478
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Oh yeah, that's right. Forgot about that.

  8. #8
    bronze trophy
    Join Date
    Dec 2004
    Location
    Sweden
    Posts
    2,670
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    But ID won't be sent to the server, and he wanted to check which form was submitted with PHP. So ID won't help.
    Simon Pieters

  9. #9
    SitePoint Guru Rob_D's Avatar
    Join Date
    Oct 2006
    Location
    UK
    Posts
    882
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    So can use id and name? Will that validate?
    It has yet to be proven that intelligence has any survival value.
    Arthur C. Clarke

  10. #10
    bronze trophy
    Join Date
    Dec 2004
    Location
    Sweden
    Posts
    2,670
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    <form name> is not valid according to the XHTML 1.1 DTD. ID and NAME have different purposes when it comes to forms.
    Simon Pieters

  11. #11
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you want to check if the form was submitted, the easiest way is to use the name attribute on your submit button.
    HTML Code:
    <input type="submit" name="submitted" value="Submit">
    PHP Code:
    if (array_key_exists('submitted'$_POST)) {
      ...

    Birnam wood is come to Dunsinane

  12. #12
    . shoooo... silver trophy logic_earth's Avatar
    Join Date
    Oct 2005
    Location
    CA
    Posts
    9,013
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by AutisticCuckoo View Post
    If you want to check if the form was submitted, the easiest way is to use the name attribute on your submit button.
    Actually using the submit button would not be a good item to check because a certain browser fails to send it if it wasn't clicked. You should check either a required field or add a hidden field.
    Logic without the fatal effects.
    All code snippets are licensed under WTFPL.


  13. #13
    SitePoint Wizard drhowarddrfine's Avatar
    Join Date
    Aug 2005
    Posts
    3,438
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It doesn't matter, it's all out of whack to use ver. 1.1 anyway. I'd bet he's serving this as html!


Bookmarks

Posting Permissions

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