Hello, I have some php code that calls my server via a api, this code can create a new user on my server, what i need is a signup form so uses can enter information and creat the user and after the users has been made it will send a welcome message back the person who has signed up to my serivce, I would like to know how i can create this signup form in php if possible please. just some code to start me off would be great....
below is my api code
<?php
/*
* Let's make the proposed login name OBS friendly
*/
$ahsayLoginName = $proposedAhsayLoginName;
$ahsayLoginName = strtolower($ahsayLoginName);
$code_entities_match = array(' ','--','"','!','@','#','$','%','^','&','*','(',')','_','+','{','}','|',':','"','<','>','?','[',']','\\',';',"'",',','.','/','*','+','~','`','=');
$code_entities_replace = array('-','-','','','','','','','','','','','','','','','','','','','','','','','','');
$ahsayLoginName = str_replace($code_entities_match, $code_entities_replace, $ahsayLoginName);
/*
* $ahsayProfile is an internal object that contains all data needed to create an account in OBS.
* so here we basically populate an array that we will use to contruct the URI to actually make the API call
*/
$obsAccount = array (
'username' => "username", /* this is the username for the new account */
'password' => "password", /* this is the password for the new account */
'nickname' => "Name Surname",
'email' => "email@someplace.com",
'type' => "OBM",
'disksize' => "1*1073741824", /* OBS wants size in bytes */
'status' => "enable",
'clienttype' => "PAID", /* this is either PAID or TRIAL */
'language' => "EN",
'timezone' => "GMT+00:00 (BST)",
'userhome' => "\\san01-vlan101.phx1.hosteddatasolutions.net\123backup\Home Users Store",
'bandwidth' => "512*1024",
'mysqlAgent' => "false",
'mssqlAgent' => "false",
'oracleAgent' => "false",
'dominoAgent' => "false",
'notesAgent' => "false",
'exchangeAgent' => "false",
'exchangeMailboxes' => "0",
'infiledelta' => "true",
'shadowcopy' => "true",
);
/*
* Now we call the OBS API URI$ahsayProfile is an internal object that contains all data needed to create an account in OBS.
* so here we basically populate an array that we will use to contruct the URI to actually make the API call
*/
class obsConfig
{
function obsConfig()
{
$this->obsConfig['apiCall'] = 'AddUser.do';
}
}
$command = "";
if (!isset($obsAccount['username'])) {
return array (
'error' => 'No account name supplied!',
);
}
if (!isset($obsAccount['type'])) {
return array (
'error' => 'No account type supplied!',
);
}
$command .= '&LoginName='.urlencode($obsAccount['username']);
if (isset($obsAccount['password'])) {
$command .= '&Password='.urlencode($obsAccount['password']);
}
if (isset($obsAccount['nickname'])) {
$command .= '&Alias='.urlencode($obsAccount['nickname']);
}
if (isset($obsAccount['email'])) {
$command .= '&Email='.urlencode($obsAccount['email']);
}
if (isset($obsAccount['type'])) {
$command .= '&Type='.urlencode($obsAccount['type']);
}
if (isset($obsAccount['disksize'])) {
$command .= '&Quota='.urlencode($obsAccount['disksize']);
}
if (isset($obsAccount['status'])) {
$command .= '&Status='.urlencode($obsAccount['status']);
}
if (isset($obsAccount['clienttype'])) {
$command .= '&ClientType='.urlencode($obsAccount['clienttype']);
}
if (isset($obsAccount['language'])) {
$command .= '&Language='.urlencode($obsAccount['language']);
}
if (isset($obsAccount['timezone'])) {
$command .= '&Timezone='.urlencode($obsAccount['timezone']);
}
if (isset($obsAccount['bandwidth'])) {
$command .= '&Bandwidth='.urlencode($obsAccount['bandwidth']);
}
if (isset($obsAccount['userhome'])) {
$command .= '&UserHome='.urlencode($obsAccount['userhome']);
}
if (isset($obsAccount['enableAds'])) {
if ($obsAccount['enableAds']) {
$command .= '&EnableAds=Y';
} else {
$command .= '&EnableAds=N';
}
}
if (isset($obsAccount['mysqlAgent'])) {
if ($obsAccount['mysqlAgent']) {
$command .= '&EnableMySQL=Y';
} else {
$command .= '&EnableMySQL=N';
}
}
if (isset($obsAccount['mssqlAgent'])) {
if ($obsAccount['mssqlAgent']) {
$command .= '&EnableMSSQL=Y';
} else {
$command .= '&EnableMSSQL=N';
}
}
if (isset($obsAccount['oracleAgent'])) {
if ($obsAccount['oracleAgent']) {
$command .= '&EnableOracle=Y';
} else {
$command .= '&EnableOracle=N';
}
}
if (isset($obsAccount['dominoAgent'])) {
if ($obsAccount['dominoAgent']) {
$command .= '&EnableLotusDomino=Y';
} else {
$command .= '&EnableLotusDomino=N';
}
}
if (isset($obsAccount['notesAgent'])) {
if ($obsAccount['notesAgent']) {
$command .= '&EnableLotusNotes=Y';
} else {
$command .= '&EnableLotusNotes=N';
}
}
if (isset($obsAccount['exchangeAgent'])) {
if ($obsAccount['exchangeAgent']) {
$command .= '&EnableMSExchange=Y';
} else {
$command .= '&EnableMSExchange=N';
}
}
if (isset($obsAccount['exchangeMailboxes'])) {
if ($obsAccount['exchangeMailboxes'] > 0) {
$command .= '&EnableExchangeMailbox=Y&ExchangeMailboxQuota='.$obsAccount['exchangeMailboxes'];
} else {
$command .= '&EnableExchangeMailbox=N&ExchangeMailboxQuota=0';
}
}
if (isset($obsAccount['infiledelta'])) {
if ($obsAccount['infiledelta']) {
$command .= '&EnableInFileDelta=Y';
} else {
$command .= '&EnableInFileDelta=N';
}
}
if (isset($obsAccount['shadowcopy'])) {
if ($obsAccount['shadowcopy']) {
$command .= '&EnableShadowCopy=Y';
} else {
$command .= '&EnableShadowCopy=N';
}
}
// we add the credential infos
$command .= '&SysPwd='.$sysPwd;
$command .= '&SysUser='.$sysUser;
class obs
{
function obsConfig()
{
$this->obsConfig['uri'] = 'http://backupserver.123-backup.com/obs/api/';
{
function obsConfig()
{
$result = $this->connect($this->obsConfig['uri'], $this->obsConfig['apiCall'], $command, 'POST');
}
}
if (!$result) {
return array (
'error' => $this->error,
);
}
if (strpos($result['dataXml'], 'OK') === false) {
$x = new sfParseXmlMyRisk($result['dataXml']);
$dataArray = $x->toArray();
if(isset($dataArray['err'])) {
return array (
'error' => 'OBS API Account Creation Error: '. $dataArray['err'][0],
);
}
} else {
return null;
}
/*code for the connect call */
/**
* Private method used to connect to our destination and retrieve results
* If we return null, please check $this->error for information
* Otherwise we return an array of elements
* dataXml = raw results
* httpInfo = all Http call informations
*
* @param string url to call
* @param string api command to call (if any)
* @param string to deliver (if any)
* @param string httpd method ('POST' or 'GET') (default POST)
* @param boolean verify SSL certificate validity (default true)
* @param boolean verify SSL certificate host (default true)
* @param string user agent for HTTP request (default Mozilla 4.0)
* @return null if error or array
*/
}
function connect($url, $urlApi = null, $command = null, $method = 'POST', $verifyPeer=true, $verifyHost=true, $userAgent = 'Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)')
{
if (empty($url)) {
$this->error = 'Missing API url to call';
return null;
}
$ch = curl_init();
if (strtolower($method) == 'post') {
curl_setopt($ch, CURLOPT_URL, $url . $urlApi);
curl_setopt($ch, CURLOPT_POST,1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $command);
} else {
curl_setopt($ch, CURLOPT_POST,0);
curl_setopt($ch, CURLOPT_URL, $url . $urlApi . $command);
}
curl_setopt($ch, CURLOPT_VERBOSE,1);
curl_setopt($ch, CURLOPT_USERAGENT, $userAgent);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, $verifyPeer);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, $verifyHost);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
$dataXml = curl_exec($ch);
$curlError = curl_error($ch);
if($curlError) {
$this->error = 'Curl Error: '.$curlError;
return null;
}
$info = curl_getinfo($ch);
if (empty($info['http_code'])) {
$this->error = 'No HTTP code was returned';
return null;
}
if (!(
$info['http_code'] == '200' ||
$info['http_code'] == '302'
)) {
$this->error = 'Http Code: '.$info['http_code'];
return null;
}
return array (
'dataXml' => $dataXml,
'httpInfo' => $info,
);
}}
?>