Jump to content

Archived

This topic is now archived and is closed to further replies.

ukweb

echo post variable as asteriks (***)

Recommended Posts

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 on

Many thanks

Share this post


Link to post
Share on other sites
you probably have this:

<input type="text" name="pass">

the type needs to be password

so...
<input type="password" name="password">

now everything they type in that field will show up as *'s

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
If your password is in the array element $_POST['pass'].
[code]
<?php
if (isset($_POST['pass'])) {
  $len = strlen($_POST['pass']);
  echo str_pad('', $len,'*');
}
?>
[/code]

Share this post


Link to post
Share on other sites
[!--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]
<?php
if (isset($_POST['pass'])) {
  $len = strlen($_POST['pass']);
  echo str_pad('', $len,'*');
}
?>
[/code]
[/quote]

...or...
[code]
<?php
if (isset($_POST['pass'])) echo preg_replace('|.|', '*', $_POST['pass']);
?>
[/code]

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.