shadiadiph Posted March 6, 2009 Share Posted March 6, 2009 I have a view page where my user can view their username email and password etc calling the details from the database using. $password = $row["password"]; then using <?=$password?> to display it etc but the thing is i do not want to display the actual password for example password is 123456 i do not want to display it like this I want to display it like ****** the same length as the password any ideas? Link to comment https://forums.phpfreaks.com/topic/148176-solved-need-help-with-displaying-password/ Share on other sites More sharing options...
maxudaskin Posted March 6, 2009 Share Posted March 6, 2009 Here you go: <?php $password = ''; $passLength = strlen($row["password"]); for($i = 0; $i <$passLength; $i++) { $password .= '*'; } echo $password; ?> Link to comment https://forums.phpfreaks.com/topic/148176-solved-need-help-with-displaying-password/#findComment-777816 Share on other sites More sharing options...
jackpf Posted March 6, 2009 Share Posted March 6, 2009 Something like this- $length = strlen($password); for($i = 0; $i <= $length; $i++) { echo '*'; } Hope this helps... Link to comment https://forums.phpfreaks.com/topic/148176-solved-need-help-with-displaying-password/#findComment-777818 Share on other sites More sharing options...
jackpf Posted March 6, 2009 Share Posted March 6, 2009 LOL, put the exact same thing as you; great minds think alike Actually, yours is probably better tbh, but it is 1:30am... Link to comment https://forums.phpfreaks.com/topic/148176-solved-need-help-with-displaying-password/#findComment-777819 Share on other sites More sharing options...
maxudaskin Posted March 6, 2009 Share Posted March 6, 2009 Yeah... Here is a commented version so you know what is happening. <?php $password = ''; // Declare the password so that you don't get an error $passLength = strlen($row["password"]); // Get the password length for($i = 0; $i <$passLength; $i++) // Loop to get the required amount of asterixes { $password .= '*'; } echo $password; // Output the masked password ?> Edit: Jackpf, your loop will run one too many times. Link to comment https://forums.phpfreaks.com/topic/148176-solved-need-help-with-displaying-password/#findComment-777821 Share on other sites More sharing options...
shadiadiph Posted March 6, 2009 Author Share Posted March 6, 2009 thank you very much works fine Link to comment https://forums.phpfreaks.com/topic/148176-solved-need-help-with-displaying-password/#findComment-777831 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.