问题
On most sites on the register user part they want you to enter password 2 times. Why is that? Why not just one input where you enter password? Why do you have to "confirm" it.
You know
Username Password Confirm password Submit
This has been on my mind for a while...
Hope somebody can answer this.
Thanks
回答1:
It is to avoid typos. If you have to type the password twice chances are you'll make your password what you want. They want to avoid having people whose password is "blah" having to retrieve their password later on because they typed "blaj" by mistake. This is especially true since password fields show as asterisks (*********
) and sometimes it is hard to tell if you typed what you thought you typed - people are likely to make typos without even realizing it. Some websites do this too with the email address when it is essential that is correct as well.
By the way: I am not sure why PHP is mentioned at all, this has nothing to do with PHP and is used in all kinds of websites. :)
回答2:
If you use an input
element of the type password
(that you should!) the entered text will not be shown. Instead every character is represented by a *
or •
to at least get a feedback for the length.
So you cannot see if you spelled your password correctly. Therefor you are asked to enter your password twice and the application checks if both entered passwords are identical.
But this doesn’t prevent that both times the password is entered incorrectly.
来源:https://stackoverflow.com/questions/575142/why-enter-password-2-times