The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Please Help with auto create script issue plz!

Discussion in 'General Discussion' started by Jayreis, Jul 10, 2006.

  1. Jayreis

    Jayreis Member

    Joined:
    Feb 13, 2002
    Messages:
    16
    Likes Received:
    0
    Trophy Points:
    1
    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);
    ?>
     
  2. webignition

    webignition Well-Known Member

    Joined:
    Jan 22, 2005
    Messages:
    1,880
    Likes Received:
    0
    Trophy Points:
    36
    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.
     
  3. Jayreis

    Jayreis Member

    Joined:
    Feb 13, 2002
    Messages:
    16
    Likes Received:
    0
    Trophy Points:
    1
    ....

    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
     
  4. ircmaxell

    ircmaxell Member

    Joined:
    Mar 20, 2006
    Messages:
    14
    Likes Received:
    0
    Trophy Points:
    1
    Try
    require('account.php');
    that will run account.php, but at the same time pass all environment variables ($_POST) to the next script...
     
Loading...

Share This Page