LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 12-24-2011, 01:37 AM   #1
magicalshashank31
Member
 
Registered: Apr 2011
Posts: 81
Blog Entries: 1

Rep: Reputation: 0
exec() in php script not working


i have made postfix mailserver in centos6 and i want to send and receive mails via webpage , first i made a html page to create users :

Code:
<html>
<body>

<form action="create_user.php" method="POST">
Username: <input type="text" name="username" /><br />
Password: <input type="text" name="password" />
<input type="submit" />
</form>

</body>
</html>
and create_user.php is

Code:
<html>
<body>
<?php
echo $_POST[username];
$user = $_POST[username];
$password = $_POST[password];
exec ("sudo /sbin/useradd $user -p $password" );

?>

</body>
</html>
but no user added please someone tell is i am doing right or i have to do something else for createing users.
 
Old 12-24-2011, 10:31 AM   #2
anomie
Senior Member
 
Registered: Nov 2004
Location: Texas
Distribution: RHEL, Scientific Linux, Debian, Fedora
Posts: 3,935
Blog Entries: 5

Rep: Reputation: Disabled
Check PHP's logging, or turn on display_errors. It's a lot easier to debug problems when you let PHP tell you what is wrong (rather than guessing).

And, seriously: You are accepting user input, you are not validating it or scrubbing it, and then you are passing it to the shell.

Please read the OWASP Top 10 (in particular, the very first item on the list), and do not deploy your application until you've addressed it.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
calling script from php page is not working xerox Programming 3 03-03-2011 12:12 AM
Portion of client's PHP script not working - please help picklepie1 Programming 7 04-30-2009 09:55 PM
PHP script is not working. mmsaulon Linux - Newbie 6 01-20-2009 01:28 AM
PHP script through cron not working fine. vikasumit Linux - General 5 09-04-2008 02:22 PM
why isn't this php symlink script working verbatim Programming 8 04-27-2005 09:13 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:31 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration