the second problem is solved. I used "sudo" to run the useradd command as a superuser and it worked.
The first problem is still there: I can't find a way to set the password. useradd manual says that I should use the crypt() function from C.
I need a PHP equivalent if someone knows about it.
I also tried to run:
passthru("sudo -u root passwd "$login"\n".$pwd."\n".$pwd);
I don't know if \n can be accepted into a command but this doesn't seem to work.