Jump to content

Form and name


ChrisMartino

Recommended Posts

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

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.