ChrisMartino Posted August 22, 2009 Share Posted August 22, 2009 hey i would like it so in a form the user fills out there eg a form with username and password and with that data it creates the ftp account and file named after that data heres the code <?php echo exec('cd /home/users'); echo exec('mkdir user_name'); echo exec('useradd user_name -p your_password -d /home/users -s /bin/false'); ?> so how would i make it create the dir and the ftp user and password off the data submited in the form? so replace the user_name with the username they submited in the form. anyone know please? Link to comment https://forums.phpfreaks.com/topic/171423-form-and-name/ Share on other sites More sharing options...
thebadbad Posted August 22, 2009 Share Posted August 22, 2009 No offence, but if you don't know how to do that, chances are you aren't aware of the security implications of feeding user input to a function like exec(). You can read about variables here in the manual: http://dk.php.net/manual/en/language.variables.php The chapter "Variables From External Sources" deals with user input from a HTML form. And when you get to feeding the user input to exec(), have a look at these functions: escapeshellarg(), escapeshellcmd() Link to comment https://forums.phpfreaks.com/topic/171423-form-and-name/#findComment-904052 Share on other sites More sharing options...
ChrisMartino Posted August 22, 2009 Author Share Posted August 22, 2009 i thought php is server sided whats the worst they can do? Link to comment https://forums.phpfreaks.com/topic/171423-form-and-name/#findComment-904055 Share on other sites More sharing options...
trq Posted August 26, 2009 Share Posted August 26, 2009 Take control of your server. Link to comment https://forums.phpfreaks.com/topic/171423-form-and-name/#findComment-906572 Share on other sites More sharing options...
Garethp Posted August 26, 2009 Share Posted August 26, 2009 You want something like $string = 'useradd ' . $_POST['username'] . ' -p ' . $_POST['password'] . ' -d /home/users -s /bin/false'; exec($string); But as the guys above said, without the proper security, they could do anything and everything they wanted, if you let them. And all it takes to let them is not knowing how to deal with insecure inputs Link to comment https://forums.phpfreaks.com/topic/171423-form-and-name/#findComment-906577 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.