Kez323 Posted August 16, 2013 Share Posted August 16, 2013 Hey, i want the '***' to change depending on the length of the persons password. any way to echo a variable like this? Quote Link to comment https://forums.phpfreaks.com/topic/281246-php-echo-variable-as-stars/ Share on other sites More sharing options...
Solution trq Posted August 16, 2013 Solution Share Posted August 16, 2013 Passwords are stored (or at least should be) as a hash, so there is no way of knowing how long the original password is. Are you planning an storing the length of the unhashed password somewhere? Then you could just use: echo str_repeat("*", $passlength); Quote Link to comment https://forums.phpfreaks.com/topic/281246-php-echo-variable-as-stars/#findComment-1445351 Share on other sites More sharing options...
.josh Posted August 16, 2013 Share Posted August 16, 2013 What's the point in even having a line that says "Current Password: **********" anyways? What function does that possibly serve anyone? The only "useful" thing that's related is when password change forms require you to ENTER your current password, in addition to the new one, as final verification. Simply displaying a line of text with stars is pointless and IMO kinda dumb. Quote Link to comment https://forums.phpfreaks.com/topic/281246-php-echo-variable-as-stars/#findComment-1445353 Share on other sites More sharing options...
Kez323 Posted August 16, 2013 Author Share Posted August 16, 2013 Thanks trq. .josh, This is a forums. Im here to ask questions, you don't have to be a grumpy fuck. Doesn't matter what its for. Quote Link to comment https://forums.phpfreaks.com/topic/281246-php-echo-variable-as-stars/#findComment-1445354 Share on other sites More sharing options...
Irate Posted August 16, 2013 Share Posted August 16, 2013 <input type="password"> That'll hide the user input from views, if it's that what you need. Otherwise, trq provided a solution. Quote Link to comment https://forums.phpfreaks.com/topic/281246-php-echo-variable-as-stars/#findComment-1445365 Share on other sites More sharing options...
.josh Posted August 16, 2013 Share Posted August 16, 2013 Thanks trq. .josh, This is a forums. Im here to ask questions, you don't have to be a grumpy fuck. Doesn't matter what its for. Yep, this is a forums, and you are here to ask questions. And you did get an answer. However, I'm free to point out when something isn't a "best practice" or generally not a good idea, or just plain stupid. It's like if my kid were to ask me what's the best way to make a homemade parachute to jump out of a tree. I could tell him which sheet to use and how to tie the rope around the corners..or I could tell him that jumping out of a tree with a homemade parachute is damn stupid. We aren't here to just blindly answer questions. We're here to try and help people become better programmers. Sometimes becoming a better programmer is recognizing that there are better ways to do what you are doing, or accepting that what you are doing doesn't make sense or is just stupid. Instead of acting like a 2 year old stomping your feet, swallow your pride and listen to advice given, and you just might learn something. Quote Link to comment https://forums.phpfreaks.com/topic/281246-php-echo-variable-as-stars/#findComment-1445370 Share on other sites More sharing options...
Psycho Posted August 16, 2013 Share Posted August 16, 2013 FWIW: Displaying any information about a password - even it's length is a bad practice. You should not provide any information about a user's password. A malicious user could use that information to narrow the possibilities of passwords to try. And, as stated above, it provides no value to the user. Plus, if I was ever to see that on an application, my first reaction would be to assume they are not hashing my password and would be a huge red flag. That would never pass a security audit. Quote Link to comment https://forums.phpfreaks.com/topic/281246-php-echo-variable-as-stars/#findComment-1445374 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.