Jump to content


Photo

echo post variable as asteriks (***)


  • Please log in to reply
4 replies to this topic

#1 ukweb

ukweb
  • Members
  • PipPipPip
  • Advanced Member
  • 119 posts
  • LocationLlandudno, North Wales

Posted 05 June 2006 - 11:25 AM

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

#2 localhost

localhost
  • Members
  • PipPipPip
  • Advanced Member
  • 152 posts

Posted 05 June 2006 - 11:32 AM

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

#3 poirot

poirot
  • Members
  • PipPipPip
  • Advanced Member
  • 646 posts
  • LocationAustin, TX

Posted 05 June 2006 - 02:06 PM

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.
~ D Kuang

#4 trq

trq
  • Staff Alumni
  • Advanced Member
  • 31,041 posts

Posted 05 June 2006 - 02:08 PM

If your password is in the array element $_POST['pass'].
<?php
if (isset($_POST['pass'])) {
  $len = strlen($_POST['pass']);
  echo str_pad('', $len,'*');
}
?>


#5 obsidian

obsidian
  • Staff Alumni
  • Advanced Member
  • 3,202 posts
  • LocationSeattle, WA

Posted 05 June 2006 - 02:39 PM

[!--quoteo(post=380208:date=Jun 5 2006, 10:08 AM:name=thorpe)--][div class=\'quotetop\']QUOTE(thorpe @ Jun 5 2006, 10:08 AM) View Post[/div][div class=\'quotemain\'][!--quotec--]
If your password is in the array element $_POST['pass'].
<?php
if (isset($_POST['pass'])) {
  $len = strlen($_POST['pass']);
  echo str_pad('', $len,'*');
}
?>
[/quote]

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

You can't win, you can't lose, you can't break even... you can't even get out of the game.

<?php
while (count($life->getQuestions()) > 0)
{   $life->study(); } ?>
  LINKS: PHP: Manual MySQL: Manual PostgreSQL: Manual (X)HTML: Validate It! CSS: A List Apart | IE bug fixes | Zen Garden | Validate It! JavaScript: Reference Cards RegEx: Everything RegEx




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users