Hi Guys,

im confused here,

im writing a script to show password as *.

My code at this minute does the following.

Passwords retrieved from database,
Password gets counted,
Password then gets changed into *
Password then gets printed to screen,

The code i have just now.

<?php
		  	$user = $_SESSION['myusername'];
	$data = mysql_query("SELECT * FROM `members` WHERE username='$user'");
		   while($row = mysql_fetch_array($data, MYSQL_ASSOC))
	 		{
			$password = "{$row['password']}";
			$length = strlen($password);
			$start = "*";
			$new_pword = str_replace($password, $start, $password);
		   echo "$new_pword"; 
		   }
		   ?>

my problem is that it only shows 1 star when it should count the password and use that many stars

if you have a look in the manual (php.net/str_replace) you can see that you are instructing php to replace the whole word with a single star.

$password = preg_replace('.', '*', $password);
// or
$password = str_repeat('*', $length);
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.