HTML & PHP question


In my HTML form, I have this line:

<input type="text" name="email" id="email"/>

and in my PHP above the HTML, I have this line:

$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.

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. :slight_smile: