Angelo Kreikamp Angelo Kreikamp - 1 month ago 14
PHP Question

php syntax error while creating an email in directadmin by api

I'm trying to create an email into DirectAdmin by API
but my codes give back a syntax error on line 10 but i don't see anything wrong with that line.

<?php
include('../da_api');
$sock = new HTTPSocket;
$sock->connect('mijndomein',2222);
$sock->set_login('mijndomein','mijn 1337 ww');

if(!empty($_POST['user']) && !empty($_POST['passwd']) is_numeric($_POST['quota'])) {
$sock->query('/CMD_API_POP','domain=mijndomein&quota='.$_POST['quota'].'&action=create&user='.$_POST['user'].'&passwd='.$_POST['passwd'].'');
echo $sock->result;

if(eregi('error=0', $sock->result)){
echo '<p>Email adress is aan gemaakt<br />
username: '.$_POST['user'].'@mijndomein.nl<br />
password: '.$_POST['passwd'].'<br />
Quota: '.$_POST['quota'].'<br />
POP3 server: mail.mijndoemin.nl<br />
SMTP server: mail.mijndomein.nl*</p>';
}
}
?>

Answer

You missed logical operator within if statement

if(!empty($_POST['user']) && !empty($_POST['passwd']) is_numeric($_POST['quota'])){
                                                     ^^^

should be

if(!empty($_POST['user']) && !empty($_POST['passwd']) && is_numeric($_POST['quota'])){
                                                      ^^^