Page 1 of 1

Adding nologin users from a PHP form

Posted: Wed Aug 16, 2006 5:51 am
by impulse()
At the moment I have a very unexperienced bit of code, which doesn't actually work, well :) I use a HTML form to post a variable of the username from a form input to the PHP document. I used the shell_exec command to run 'useradd -s /sbin/nologin'.

Code: Select all

<?php

$inputUser = $_REQUEST["user"];

$shellCmdUsername = shell_exec('useradd -s /sbin/nologin $inputUser');

print "$shellCmdUsername";
print "Username $inputUser created<br>";
?>
I get the "user created" message on the PHP form, but it doesn't actually create a user.

My query isn't actually to get this working, it's to find a more efficiant way to perform this task.

Regards, Stephen

Posted: Wed Aug 16, 2006 8:16 am
by feyd
single quotes vs. double quotes problem.

have a read: http://php.net/language.types.string