Adding nologin users from a PHP form

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
impulse()
Forum Regular
Posts: 748
Joined: Wed Aug 09, 2006 8:36 am
Location: Staffordshire, UK
Contact:

Adding nologin users from a PHP form

Post 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
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

single quotes vs. double quotes problem.

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