The difference between username and loginName In the examples they're used mixed: 

Registration

&lt;input id="username" type="text" name="username"
{%- if account is defined %} value="{{ account.username }}"{% endif -%}&gt;


Login

 &lt;input id="loginName" type="text" name="loginName"
    value="{{ craft.session.rememberedUsername }}"&gt;


For the login form, a field named "username" can not be used, it should be "loginName". What is the difference between the two?
Because you can login with either your email address or your username.  And some sites will be forcing the username to be the email address.