1

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>';
    }
  }
?>
Marek Skiba
  • 2,124
  • 1
  • 28
  • 31

3 Answers3

3

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'])){
                                                      ^^^
Narendrasingh Sisodia
  • 21,247
  • 6
  • 47
  • 54
2

Wrong syntax for if. Missing operator && or || before is_numeric(). It should be -

if(!empty($_POST['user']) && !empty($_POST['passwd']) && is_numeric($_POST['quota'])){
Sougata Bose
  • 31,517
  • 8
  • 49
  • 87
2

You missed the logical operator at this line most probabaly you were indenting to write: || or && operator there, before the is_numeric($_POST['quota']) in the if condition, it should be like

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

or

if(!empty($_POST['user']) && !empty($_POST['passwd']) || is_numeric($_POST['quota']))
Sourabh Kumar Sharma
  • 2,864
  • 3
  • 25
  • 33