SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast ParfaitMacaron's Avatar
    Join Date
    Mar 2013
    Posts
    43
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    HTML & PHP question

    Hi,

    In my HTML form, I have this line:

    Code:
    <input type="text" name="email" id="email"/>
    and in my PHP above the HTML, I have this line:

    PHP Code:
    $email mysql_real_escape_string($_POST['email']); 
    In the HTML, please can someone tell me the difference between name="email" and id="email"

    which one is the 'email' in the PHP code taken from? name or id? Do I need both name and id?

    Thank you.

  2. #2
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    24,301
    Mentioned
    460 Post(s)
    Tagged
    8 Thread(s)
    Quote Originally Posted by ParfaitMacaron View Post
    which one is the 'email' in the PHP code taken from? name or id?
    It's taken from name="".

    The ID is used for associating the <label> with the <input> (assuming there is one). The <label> should have for="email" to associate it with this input. Then a user can clearly know that the label and input are directly connected.

  3. #3
    SitePoint Enthusiast ParfaitMacaron's Avatar
    Join Date
    Mar 2013
    Posts
    43
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by ralph.m View Post
    It's taken from name="".

    The ID is used for associating the <label> with the <input> (assuming there is one). The <label> should have for="email" to associate it with this input. Then a user can clearly know that the label and input are directly connected.
    I understand! Thank you so much for answering.


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
  •