useradd - not working with -p option


I have a PHP script that is trying to add a user. Here's a simplified snippet:

After running this script, I see the user test in the /etc/passwd file. However, I don't see password in the /etc/shadow file. My gut feeling is that I am incorrectly setting the password somehow.

Any ideas what I am doing wrong? Thanks.


When I create the user via the command line and add the password using passwd command, the encrypted string I see in /etc/shadow is very different from what the crypt function in my PHP script generates.


Per mario's suggestion:

NOTE: this has not fixed anything for me. Problem is still the same.