LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 05-02-2005, 11:52 AM   #1
chetshot
LQ Newbie
 
Registered: May 2005
Posts: 2

Rep: Reputation: 0
php adduser thru system()


hi folks..
i want to make a sendmail signup page:
using adduser -s /sbin/nologin command thru system() function of php:
i have developed the following code.....but i dont knw php much....can anybody edit this and tell me what to do to get the textbox input in the command>>>?



<?php

global $confirmPass,$gochange ,$new_pw1,$username, $ret, $output;

//system(adduser -s /sbin/nologin $User ; passwd $new_pw1);

$safe_newpw = escapeshellarg($new_pw1);
$safe_oldpw = escapeshellarg($old_pw);
$safe_user = escapeshellarg($user);

if ($gochange)
{

echo '<pre>';
$output= system('adduser -s /sbin/nologin $user ; passwd $user $new_pw1', $ret);

echo '
</pre>
<hr/>fhg :' . $output .'
<hr/>f :' . $ret ;
}

?>

<form method="post">
<input type="hidden" name="gochange" value="1" />
<center>
<hr noshade />
<table>
<tr>
<td align="right"><?php echo _("Your user name:"); ?></td>
<td><b><?php echo $username?></b>
<input type="text" name="user" value="<?php echo $username; ?>" />
</td>
</tr>

<tr>
<td align="right"><?php echo _("New password:"); ?> </td>
<td><input name="new_pw1" size="10" type="password" maxlength="50" /> </td>
</tr>
</table>
<hr noshade />
<input name="change" type="submit" value="<?php echo _("Change Password"); ?>" />
</center>
</form>
</td>
</tr>
<tr>
<td> </td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>
 
Old 05-02-2005, 05:00 PM   #2
michaelsanford
Member
 
Registered: Feb 2005
Location: Ottawa/Montréal
Distribution: Slackware + Darwin (MacOS X)
Posts: 468

Rep: Reputation: 30
In the newest versions of PHP you need to use what are called superglobal variables to access POST and GET (and session and cookie and server) data. Drop that global at the beginning of the script since none of the variables you define are used outside the script, they don't need to be globbed.

Firstly, you need to set the form tag's action="script.php" so it actually sends data to the form

Then, in the PHP script you reference the variables as $_POST['form_element_name'] like
PHP Code:
$safe_newpw escapeshellarg($_POST['new_pw1']);
$safe_oldpw escapeshellarg($_POST['old_pw']);
$safe_user escapeshellarg($_POST['user']); 
EDIT Addition: I noticed you have if ($gochange) but you don't have a form element called that. You can indeed do soemthing like this, but you need to say something like
PHP Code:
if (isset($_POST['change'])) {do everything
where "change" is the name of your submit button, as in your example.

PS Cudos on the use of escapedshellarg() many new php programmers don't bother escaping shell commands, as you must.

Last edited by michaelsanford; 05-02-2005 at 05:10 PM.
 
  


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
php adduser chetshot Linux - Networking 1 05-02-2005 12:00 PM
sendmail adduser sbin/nologin using php mhatre kedar Linux - Networking 0 04-18-2005 01:12 AM
php squirrelmail system() mhatre kedar Programming 0 04-15-2005 02:33 AM
PHP adduser da_tibmeister Programming 0 08-17-2004 09:04 PM
php and system() Marble Linux - Security 5 07-09-2003 08:27 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 07:10 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