Jump to content

[SOLVED] need help with displaying password


shadiadiph

Recommended Posts

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?

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.

Archived

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

×
×
  • Create New...

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.