Hiya there,
Thanks for your help and your php code submittion however it isnt working if you see the code below and scroll down to line 83 where your code starts. See if its something that im doing wrong!!! all the other code above line 83 is my code thats in the page where i want your code to work in.
[php]<?php
include("./xmlapi.php"); //XMLAPI cpanel client class
// Default whm/cpanel account info
$ip = “localhost”; // should be WHM ip address
$account = “dbusername”; // cpanel user account name
$passwd =“dbpassword”; // 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 = 50; // 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”;
}
/***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 = “Email password does not match”;
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
’;
//print_r($result);
//echo ‘
’;
if ($result->data->result == 1){
$msg = $email_user.’@’.$email_domain.’ account created’;
} else {
$msg = $result->data->reason;
break;
}
break;
}
?>
<?php echo '
'.$msg.'
'; ?>
<?php // START OF YOUR CUSTOM CODE
$con = mysql_connect(localhost,username,password); // the connection to ur database
$db = mysql_select_db(mydatabasename); // select the database name
$rs = mysql_query("select * from mytablename"); // the sql query to fetch records from ur table
if(mysql_num_rows($rs)>0)
{
if($row['value']=='') // display the html form
{ ?>
// THIS IS THE START OF MY FORM
Username: |
|
Password: |
|
Verify Password: |
|
|
// THIS IS THE END OF MY FORM
<?php } else // display the css div with message // THIS IS WHERE YOUR CODE RESTARTS
{ ?>
<div class="error">Sorry, you already have data created on <?= $row['created_at']; ?>.
<?php }
}
else
echo ‘Failed to retrieve records’;
?> // END OF YOUR CUSTOM CODE[/php]
I have also provided a picture of the table from phpmyadmin to show you how the table inside the database is structured. Please see below.
Please do let me know why you think its not working. Thanks so much in advance for all your valued help.