I have the following code that is part of a CLI script. As you can see from the comment, I don't know what to change so that when the user types in the database password the screen either doesn't display anything or masks the input with another character.
Does anyone have a good idea? I'm running on Windows currently, but I'd like to make it as platform independent as possible. I've already tried using exec() and system() to send the 'ECHO OFF' command, but no dice.
PHP:
[COLOR=green]// Check if database password flag was set but a password was not provided. If
// so, prompt for it and grab from STDIN. The input needs to either be masked
// or not echo to the command line in the first place. Not sure how to do that.[/color]
[b]if[/b] (isset($db_pass) && $db_pass == [COLOR=orange]"\0"[/color]) {
$line = [COLOR=orange]""[/color];
[b]while[/b] ($line == [COLOR=orange]""[/color]) {
echo [COLOR=orange]"Enter database password for user $db_user: "[/color];
$line = trim(fgets(STDIN));
}
$db_pass = $line;
}
Does anyone have a good idea? I'm running on Windows currently, but I'd like to make it as platform independent as possible. I've already tried using exec() and system() to send the 'ECHO OFF' command, but no dice.