Ok i have a little problem, i am new to PHP and am trying to add a <div> message class to the 3 or 4 $msg outputs i have in the code below. Now when i upload this file to my server i get the following error message come up "Parse error: syntax error, unexpected T_STRING in /home/username/public_html/dir/create.php on line 45" whitch is " $msg = "<div class="error">Email password does not match</div>"; " whitch was the first $msg output i wanted to test my new <div> class on. Can anyone help me with this?

<?php

include("./xmlapi.php");   //XMLAPI cpanel client class

// Default whm/cpanel account info

$ip = "localhost";           // should be WHM ip address
$account = "username";        // cpanel user account name
$passwd ="password";        // cpanel user password
$port =2083;                 // cpanel secure authentication port unsecure port# 2082

$email_domain = 'domain.com'; // email domain (usually same as cPanel domain)
$email_quota = 10; // default amount of space in megabytes


/*************End of Setting***********************/

function getVar($name, $def = '') {
  if (isset($_REQUEST[$name]))
    return $_REQUEST[$name];
  else 
    return $def;
}
// check if overrides passed
$email_user = getVar('user', '');
$email_pass = getVar('pass', $passwd);
$email_vpass = getVar('vpass', $vpasswd);
$email_domain = getVar('domain', $email_domain);
$email_quota = getVar('quota', $email_quota);

$msg = '';
if (!empty($email_user))
while(true) {


if ($email_pass !== $email_vpass){       //check password
$msg = "<div class="error">Email password does not match</div>";
break;
}

$xmlapi = new xmlapi($ip);

$xmlapi->set_port($port);  //set port number. cpanel client class allow you to access WHM as well using WHM port.

$xmlapi->password_auth($account, $passwd);   // authorization with password. not as secure as hash.

// cpanel email addpop function Parameters
$call = array(domain=>$email_domain, email=>$email_user, password=>$email_pass, quota=>$email_quota);

$xmlapi->set_debug(0);      //output to error file  set to 1 to see error_log.

$result = $xmlapi->api2_query($account, "Email", "addpop", $call ); // making call to cpanel api

//for debugging purposes. uncomment to see output
//echo 'Result\n<pre>';
//print_r($result);  
//echo '</pre>'; if ($result->data->result == 1){ $msg = $email_user.'@'.$email_domain.' account created'; } else { $msg = $result->data->reason; break; } break; } ?> <html> <body> <?php echo ''.$msg.''; ?> <h1>Create Your New Mailbox</h1> <form name="frmEmail" method="post"> <table width="400" border="0"> <tr><td>Username:</td><td><input name="user" size="20" type="text" /></td></tr> <tr><td>Password:</td><td><input name="pass" size="20" type="password" /></td></tr> <tr><td>Verify Password:</td><td><input name="vpass" size="20" type="password" /></td></tr> <tr><td colspan="2" align="center"><hr /><input name="submit" type="submit" value="Create Email" /></td></tr> </table> </form> </body> </html>

    either escape the inner quotes or change the outer\inner quotes so one set is single, one double.

      dagon;10974470 wrote:

      either escape the inner quotes or change the outer\inner quotes so one set is single, one double.

      Like i said i am new to PHP so please do enlighten a little more on what you mean by this.

      One more thing i would also like to ban cirtain usernames like "admin" and "sales" from being used. So if you could explain or add the code to the above code with the first correction that would be really helpful and so kind of you.

      Thanks in advance.

        Ok i have managed the outer\inner quotes thingy you said now i have the small issue of adding some new code into the file to ban usernames.

          malvernphpman;10974474 wrote:

          Ok i have managed the outer\inner quotes thingy you said now i have the small issue of adding some new code into the file to ban usernames.

          if there are not to may, i would put them in an array the use in_array() to check.

            So would something like this work

            $user = array('admin','administrator','sales');
            
            $ip = $_SERVER['REMOTE_ADDR'];
            
            for($i=0;$i<3;$i++){
            if($ip == $user[$i]) {
            echo "You are currently trying to use a banned username, sorry!";
            die();
            } else {
            // carry on with site rendering
            }
            } 

              I dont remember or see an array() that you posted

              Will this work then?

              <?php
              $banned[0]*=*"admin";
              
              if*(in_array($user['user'],*$banned))
              //*Continue*on*with*the*registration*process.
              {
              echo*"Your of picked a username that is restricted. If*you*believe*you*have*received*this*in*error*contact*us.";
              echo*"admin@blah.net";
              }
              ?>

                By the way i dont know where all the *** have come from they are not in the code i have here.

                  in_array, it's a function it's underlined in blue because i linked to the manual (3 times now), look at example 1.

                    Sorry do excuse my "Blond moment" like i said i am very new to php hence why i am in the newbees! section of the website so people here may need more help than your average developer

                    Ok here is some code i have come up with tell me if you think this would work

                    <?php
                    $user*=*array('user',*admin,*administrator);
                    
                    if*(in_array('user',*$user,*true))*{
                    ****echo*"Sorry you are using a banned username\n";
                    }
                    ?> 

                      Right i have another error to deal with now that its displaying and that is "Parse error: syntax error, unexpected T_VARIABLE in /home/user/public_html/dir/create.php on line 26"

                      I have put the code below with the new array in it and its clear where i have put it with the tags that i have created to show where it starts and ends

                      <?php
                      
                      include("./xmlapi.php");   //XMLAPI cpanel client class
                      
                      // Default whm/cpanel account info
                      
                      $ip = "localhost";           // should be WHM ip address
                      $account = "database";        // cpanel user account name
                      $passwd ="password";        // cpanel user password
                      $port =2083;                 // cpanel secure authentication port unsecure port# 2082
                      
                      $email_domain = 'domain.com'; // email domain (usually same as cPanel domain)
                      $email_quota = 10; // default amount of space in megabytes
                      
                      /********Start Of Custome Username Ban Array*******/
                      
                      $user*=*array('user',*admin,*administrator);
                      if*(in_array('user',*$user,*true))*{
                      ****echo*"Sorry you are using a banned username\n";
                      }
                      
                      /*************End of Setting***********************/
                      
                      function getVar($name, $def = '') {
                        if (isset($_REQUEST[$name]))
                          return $_REQUEST[$name];
                        else 
                          return $def;
                      }
                      // check if overrides passed
                      $email_user = getVar('user', '');
                      $email_pass = getVar('pass', $passwd);
                      $email_vpass = getVar('vpass', $vpasswd);
                      $email_domain = getVar('domain', $email_domain);
                      $email_quota = getVar('quota', $email_quota);
                      
                      $msg = '';
                      if (!empty($email_user))
                      while(true) {
                      
                      
                      if ($email_pass !== $email_vpass){       //check password
                      $msg = '<div class="error">Email password does not match</div>';
                      break;
                      }
                      
                      $xmlapi = new xmlapi($ip);
                      
                      $xmlapi->set_port($port);  //set port number. cpanel client class allow you to access WHM as well using WHM port.
                      
                      $xmlapi->password_auth($account, $passwd);   // authorization with password. not as secure as hash.
                      
                      // cpanel email addpop function Parameters
                      $call = array(domain=>$email_domain, email=>$email_user, password=>$email_pass, quota=>$email_quota);
                      
                      $xmlapi->set_debug(0);      //output to error file  set to 1 to see error_log.
                      
                      $result = $xmlapi->api2_query($account, "Email", "addpop", $call ); // making call to cpanel api
                      
                      //for debugging purposes. uncomment to see output
                      //echo 'Result\n<pre>';
                      //print_r($result);  
                      //echo '</pre>'; if ($result->data->result == 1){ $msg = $email_user.'@'.$email_domain.' account created'; } else { $msg = $result->data->reason; break; } break; } ?> <html> <body> <?php echo ''.$msg.''; ?> <h1>Create Your New Mailbox</h1> <form name="frmEmail" method="post"> <table width="400" border="0"> <tr><td>Username:</td><td><input name="user" size="20" type="text" /></td></tr> <tr><td>Password:</td><td><input name="pass" size="20" type="password" /></td></tr> <tr><td>Verify Password:</td><td><input name="vpass" size="20" type="password" /></td></tr> <tr><td colspan="2" align="center"><hr /><input name="submit" type="submit" value="Create Email" /></td></tr> </table> </form> </body> </html>

                      Again it looks like there are ** where there shouldnt be in the code above but they are not in the code i have on file this end.

                        that would be the extra *'s they must be something else on your end, what are you using as an editor?

                          What everything i do when i go to post the code on this site puts them blinkin ** there i dont know why. If you can imagin they are not there and go from there.

                            Ok try this it may have had something to do with the /******/ tag wrapper i had put around the array to show where it was and VB was getting confused with it.

                            <?php
                            
                            include("./xmlapi.php");   //XMLAPI cpanel client class
                            
                            // Default whm/cpanel account info
                            
                            $ip = "localhost";           // should be WHM ip address
                            $account = "database";        // cpanel user account name
                            $passwd ="password";        // cpanel user password
                            $port =2083;                 // cpanel secure authentication port unsecure port# 2082
                            
                            $email_domain = 'domain.com'; // email domain (usually same as cPanel domain)
                            $email_quota = 10; // default amount of space in megabytes
                            
                            /*************End of Setting***********************/
                            
                            /*************Start of Username Ban Array***********/
                            
                            $user = array('user', admin, administrator);
                            if (in_array('user', $user, true)) {
                                echo "Sorry you are using a banned username\n";
                            }
                            
                            /**************End of Username Ban Array***********/
                            
                            function getVar($name, $def = '') {
                              if (isset($_REQUEST[$name]))
                                return $_REQUEST[$name];
                              else 
                                return $def;
                            }
                            // check if overrides passed
                            $email_user = getVar('user', '');
                            $email_pass = getVar('pass', $passwd);
                            $email_vpass = getVar('vpass', $vpasswd);
                            $email_domain = getVar('domain', $email_domain);
                            $email_quota = getVar('quota', $email_quota);
                            
                            $msg = '';
                            if (!empty($email_user))
                            while(true) {
                            
                            
                            if ($email_pass !== $email_vpass){       //check password
                            $msg = '<div class="error">Email password does not match</div>';
                            break;
                            }
                            
                            $xmlapi = new xmlapi($ip);
                            
                            $xmlapi->set_port($port);  //set port number. cpanel client class allow you to access WHM as well using WHM port.
                            
                            $xmlapi->password_auth($account, $passwd);   // authorization with password. not as secure as hash.
                            
                            // cpanel email addpop function Parameters
                            $call = array(domain=>$email_domain, email=>$email_user, password=>$email_pass, quota=>$email_quota);
                            
                            $xmlapi->set_debug(0);      //output to error file  set to 1 to see error_log.
                            
                            $result = $xmlapi->api2_query($account, "Email", "addpop", $call ); // making call to cpanel api
                            
                            //for debugging purposes. uncomment to see output
                            //echo 'Result\n<pre>';
                            //print_r($result);  
                            //echo '</pre>'; if ($result->data->result == 1){ $msg = $email_user.'@'.$email_domain.' account created'; } else { $msg = $result->data->reason; break; } break; } ?> <html> <body> <?php echo ''.$msg.''; ?> <h1>Create Your New Mailbox</h1> <form name="frmEmail" method="post"> <table width="400" border="0"> <tr><td>Username:</td><td><input name="user" size="20" type="text" /></td></tr> <tr><td>Password:</td><td><input name="pass" size="20" type="password" /></td></tr> <tr><td>Verify Password:</td><td><input name="vpass" size="20" type="password" /></td></tr> <tr><td colspan="2" align="center"><hr /><input name="submit" type="submit" value="Create Email" /></td></tr> </table> </form> </body> </html>

                            Thats better at long last...

                              Ok now i moved it out the database setting section to just under neath it i have no errors but its not working its still letting me register a banned username.

                                So is there an update on why the username ban array isnt working?

                                  Consider other IDEs. Notepad has been known to do strange things (hidden carraige returns for example).

                                  If you want to go cheap and stay with the feel of Notepad, look at Notepad++. (You should be able to find it with your favorite search engine).

                                  Get out of Notepad and into an IDE though, because just the feature of the color coding will make your life immeasurably easier in the long run - instead of you banging your head looking for errors in black and white text.