WHM - php error handling of remote access functions

jimcarter

Well-Known Member
Jun 30, 2002
152
0
166
UK
Hi,
Im trying to make a PHP script to create user accounts as soon as their payment has been authorized with paypal,
it works fine at the moment, but there is no way to check if there has been any errors creating the account, like if the username has been taken,
is there anyway to echo an error if a problem occurs when creating accounts?
thanks
 

jsteel

Well-Known Member
Jul 4, 2002
646
0
166
Atlanta, GA
just echo out the variable you assigned to the createacct function. Here's an example.

------------
$mycreateaccount = createacct($host,$user,$accesshash,$usessl,$acctdomain,$acctuser,$acctpass,$acctplan);

echo $mycreateaccount;
------------

If it errors out, the first four characters returned are 'Ouch', if it successful, the first four characters are 'WWWA' (without the quotes in both cases).

I simply trap an error condition only and assume successful otherwise.
 

jimcarter

Well-Known Member
Jun 30, 2002
152
0
166
UK
someone asked me on the forum how I do my error checking when creating accounts through PHP,
this might not be the best way to do it, but it works fine for me:

$length = strlen($acctuser);
if ($length&8){ echo &your username is longer than 8 characters, please change it!&; die; }
else {
if (is_dir(&/home/$acctuser&)){ echo &username taken, please try again&; die; }

im not sure what other errors you can have when creating accounts, I have not yet come across any,
im going to put all of my scripts for download sometime soon when I have added a few extra features, the only problem is that because I dont have 2checkout or authorize.net accounts i cannot test payment gateways with the script, except with paypal which works fine
 

jimcarter

Well-Known Member
Jun 30, 2002
152
0
166
UK
oh right, didnt know that one :p

if (eregi(&[0-9]&, $acctuser)){
echo &usernames with numbers arent allowed anymore!&;
}
 

Juanra

Well-Known Member
Sep 22, 2001
777
0
316
Spain
[quote:9d0fcf2de1][i:9d0fcf2de1]Originally posted by jimcarter[/i:9d0fcf2de1]
if (is_dir(&/home/$acctuser&)){ echo &username taken, please try again&; die; }
[/quote:9d0fcf2de1]

wwwacct checks against /etc/passwd to reject repeated usernames. Also rejects usernames greater than 8 characters long, and usernames beginning with a number or a dash.
 

jimcarter

Well-Known Member
Jun 30, 2002
152
0
166
UK
it doesnt return the errors though, and you could still end up charging someones credit card thinking that the account has been created when in fact it hasnt