faqts : Computers : Programming : Languages : PHP : Common Problems

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

37 of 87 people (43%) answered Yes
Recently 4 of 10 people (40%) answered Yes

Entry

Can I use PHP to add a new user and password to my Unix system?
How can I add a new user to my FreeBSD system using PHP?

Jul 19th, 2004 23:24
Alder Rus, Edwin Chan, Nathan Wallace, http://www.directoryonclick.com , http://www.singapore-yellow-pages.com


Try exec'ing 'adduser' from PHP.  For more information on adduser do
this at the unix command line:
   man adduser
For security's sake make sure you do some sensible checking / 
protection for the parameters.
For example,
<?php
    $passwdexe="/usr/local/bin/adduser";
    $user="myname";
    $group="users"
    $passwd="mypassword";
    $add_passwd.="$passwdexe -g $group -p $passwd $user";
    $result = system("$add_passwd");
?>