ukweb Posted June 5, 2006 Share Posted June 5, 2006 Hi.I have a page in a registration form which displays the password entered in the previous page as the actual password. How do I substitute each character with * instead, ie if the password was "hello" it would display as "*****", and so onMany thanks Link to comment https://forums.phpfreaks.com/topic/11227-echo-post-variable-as-asteriks/ Share on other sites More sharing options...
localhost Posted June 5, 2006 Share Posted June 5, 2006 you probably have this:<input type="text" name="pass">the type needs to be passwordso...<input type="password" name="password">now everything they type in that field will show up as *'s Link to comment https://forums.phpfreaks.com/topic/11227-echo-post-variable-as-asteriks/#findComment-41984 Share on other sites More sharing options...
poirot Posted June 5, 2006 Share Posted June 5, 2006 Just echo '*********' or 'Password Removed for your protection".If you use <input type="password"> people will still be able to know the password by looking at the source. Link to comment https://forums.phpfreaks.com/topic/11227-echo-post-variable-as-asteriks/#findComment-42020 Share on other sites More sharing options...
trq Posted June 5, 2006 Share Posted June 5, 2006 If your password is in the array element $_POST['pass'].[code]<?phpif (isset($_POST['pass'])) { $len = strlen($_POST['pass']); echo str_pad('', $len,'*');}?>[/code] Link to comment https://forums.phpfreaks.com/topic/11227-echo-post-variable-as-asteriks/#findComment-42025 Share on other sites More sharing options...
obsidian Posted June 5, 2006 Share Posted June 5, 2006 [!--quoteo(post=380208:date=Jun 5 2006, 10:08 AM:name=thorpe)--][div class=\'quotetop\']QUOTE(thorpe @ Jun 5 2006, 10:08 AM) [snapback]380208[/snapback][/div][div class=\'quotemain\'][!--quotec--]If your password is in the array element $_POST['pass'].[code]<?phpif (isset($_POST['pass'])) { $len = strlen($_POST['pass']); echo str_pad('', $len,'*');}?>[/code][/quote]...or...[code]<?phpif (isset($_POST['pass'])) echo preg_replace('|.|', '*', $_POST['pass']);?>[/code] Link to comment https://forums.phpfreaks.com/topic/11227-echo-post-variable-as-asteriks/#findComment-42036 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.