Please Help with auto create script issue plz!

Jayreis

Member
Feb 13, 2002
16
0
301
Ok I despereately need to get this auto account create script to work. My issue is I created a "createaccount.php" script based on the remote access script info I found on these forums. If I go to the script directly it works (creates an account on the server). Now if I use the below line inside my order form process .php file the account is not created on the server?

PHP:
if ($HTTP_POST_VARS['submit']) {
exec('/home/session/public_html/order/account.php &'); 
echo "thank you for your order";
}
my create account .php file looks like this
PHP:
#!/usr/local/cpanel/3rdparty/bin/php
<?php
$acctdomain = $_POST['domain'];
$acctuser = $_POST['username'];
$acctpass = $_POST['password'];
$acctplan = $_POST['plans'];
require '/usr/local/cpanel/Cpanel/Accounting.php.inc';
$host = "localhost";
$user = "******";
$accesshash = ' *****';
$usessl = "0";
createacct ($host,$user,$accesshash,$usessl,$acctdomain,$acctuser,$acctpass,$acctplan);
?>
 

webignition

Well-Known Member
Jan 22, 2005
1,876
2
166
You say your account creating script works fine, so that's good.

If it's not working fine when being executed through some other means, you'd have to investigate what is going wrong with the 'other means'.

In this case, you're trying to get one script to run another script using the exec() function. An odd choice, but each to their own.

Given that your script doesn't validate the input in and way and given your interesting choice of using the exec() function, I take it that you're not too experienced in using PHP.

I'd recommend getting a decent book and really learning how things work. Simply popping a script together without knowing what you're doing, and certainly without validating user input, is really really really asking for trouble. Really.
 

Jayreis

Member
Feb 13, 2002
16
0
301
....

Hello,


Well yes I am still expanding my knowledge of php. I know I should be validating the users input etc. But can I ask then what would be the best method to use to have one program run another in the background? would it be popen() or fopen() ?? both I could not get to work eaither. The reason why I now when with the php exec() command is because I read a tutorial about "forking php" which reccomended the use of exec() when having a php file run another php file. I guess it was not the greatest tutorial.


Anyway so my question is simply what is the best method to have one php file run another php file in the background?

Thanks for your help
 

ircmaxell

Member
Mar 20, 2006
14
0
151
Try
require('account.php');
that will run account.php, but at the same time pass all environment variables ($_POST) to the next script...