Jump to content

N00B Help...no doubt


CubeTech

Recommended Posts

Hi All,

 

being a noob when it comes to any sort of coding I am facing a strong learning curve but I'm getting there. With the implementation of our new client portal, we require a new client sign-up api...The following was provided...

 

<?php

//////////////////////////////////////////////////////

// THIS CODE IS PROVIDED AS AN EXAMPLE OF HOW TO

// USE THE DITTO PORTAL FOR AHSAY API'S.

//////////////////////////////////////////////////////

 

/////////////////////////////////////////////////////////////////

// SET API VARIABLES

/////////////////////////////////////////////////////////////////

 

//SET CUSTOMER ID AND API KEY

$customerID = '8000003';

$key = '6NbTmZw5LZdtTO8FuYH9G';

 

//IF POSTBACK

if ($_SERVER['REQUEST_METHOD'] == 'POST')

{

/////////////////////////////////////////////////////////////////

// GET VALUES FROM FORM

/////////////////////////////////////////////////////////////////

 

$company = $_REQUEST['company'];

$address1 = $_REQUEST['address1'];

$address2 = $_REQUEST['address2'];

$city = $_REQUEST['city'];

$state = $_REQUEST['state'];

$postal = $_REQUEST['postal'];

$country = $_REQUEST['country'];

$firstname = $_REQUEST['firstname'];

$lastname = $_REQUEST['lastname'];

$phone = $_REQUEST['phone'];

$email = $_REQUEST['email'];

$type = $_REQUEST['type'];

$username = $_REQUEST['username'];

$alias = $_REQUEST['alias'];

$language = $_REQUEST['language'];

$timezone = $_REQUEST['timezone'];

 

/////////////////////////////////////////////////////////////////

// INVOKE LIST COUNTRIES API TO POPULATE COUNTRY DROP DOWN LIST

/////////////////////////////////////////////////////////////////

 

//BUILD URL FOR API CALL

$function = 'ListCountries';

$url = 'https://api.web-portal.co/?customerID=8000003&key=6NbTmZw5LZdtTO8FuYH9G&function=ListCountries';

 

//MAKE API CALL USING SIMPLE XML

$countrylist = simplexml_load_file($url);

 

foreach ($countrylist as $c)

{

if ($country == $c->countryID)

{

$countryOptions.="<OPTION VALUE=\"".$c->countryID."\" selected>".$c->countryName."";

}

else

{

$countryOptions.="<OPTION VALUE=\"".$c->countryID."\">".$c->countryName."";

}

}

 

/////////////////////////////////////////////////////////////////

// INVOKE LIST LANGUAGES API TO POPULATE LANGUAGE DROP DOWN LIST

/////////////////////////////////////////////////////////////////

 

//BUILD URL FOR API CALL

$function = 'ListLanguages';

$url = 'https://api.web-portal.co/?customerID=8000003&key=6NbTmZw5LZdtTO8FuYH9G&function=ListLanguages';

 

//MAKE API CALL USING SIMPLE XML

$languagelist = simplexml_load_file($url);

 

foreach ($languagelist as $l)

{

if ($language == $l->languageID)

{

$languageOptions.="<OPTION VALUE=\"".$l->languageID."\" selected>".$l->languageName."";

}

else

{

$languageOptions.="<OPTION VALUE=\"".$l->languageID."\">".$l->languageName."";

}

}

 

/////////////////////////////////////////////////////////////////

// INVOKE LIST TIMEZONES API TO POPULATE TIMEZONE DROP DOWN LIST

/////////////////////////////////////////////////////////////////

 

//BUILD URL FOR API CALL

$function = 'ListTimezones';

$url = 'https://api.web-portal.co/?customerID=8000003&key=6NbTmZw5LZdtTO8FuYH9G&function=ListTimezones';

 

//MAKE API CALL USING SIMPLE XML

$timezonelist = simplexml_load_file($url);

 

foreach ($timezonelist as $t)

{

if ($timezone == $t->timezoneID)

{

$timezoneOptions.="<OPTION VALUE=\"".$t->timezoneID."\" selected>".$t->timezoneName."";

}

else

{

$timezoneOptions.="<OPTION VALUE=\"".$t->timezoneID."\">".$t->timezoneName."";

}

}

 

/////////////////////////////////////////////////////////////////

// BEFORE CALLING THE ADDCLIENT API, YOU SHOULD VALIDATE THE

// USER'S INPUT (ALL REQUIRED FIELDS COMPLETE, EMAIL ADDRESS

// ETC.

/////////////////////////////////////////////////////////////////

 

/////////////////////////////////////////////////////////////////

// INVOKE ADD CLIENT API TO ACTIVATE ACCOUNT

/////////////////////////////////////////////////////////////////

 

//SET ACCOUNT TYPE AND TRIAL LENGTH

$account = 'TRIAL';

$length = '14';

 

//BUILD URL FOR API CALL

$function = 'AddClient';

$url = 'https://api.web-portal.co/?'.

"customerID=".$customerID.

"&key=".$key.

"&function=".$function.

"&company=".$company.

"&address1=".$address1.

"&address2=".$address2.

"&city=".$city.

"&state=".$state.

"&postal=".$postal.

"&country=".$country.

"&firstname=".$firstname.

"&lastname=".$lastname.

"&phone=".$phone.

"&email=".$email.

"&type=".$type.

"&username=".$username.

"&alias=".$alias.

"&language=".$language.

"&timezone=".$timezone.

"&account=".$account.

"&length=".$length;

 

//MAKE API CALL USING SIMPLE XML

$createClient = simplexml_load_file($url);

 

//DISPLAY RESULTS OF API CALL

echo $createClient;

}

//NOT POSTBACK

else

{

/////////////////////////////////////////////////////////////////

// INVOKE LIST COUNTRIES API TO POPULATE COUNTRY DROP DOWN LIST

/////////////////////////////////////////////////////////////////

 

//BUILD URL FOR API CALL

$function = 'ListCountries';

$url = 'https://api.web-portal.co/?customerID=8000003&key=6NbTmZw5LZdtTO8FuYH9G&function=ListCountries';

 

//MAKE API CALL USING SIMPLE XML

$countrylist = simplexml_load_file($url);

 

foreach ($countrylist as $c)

{

$countryOptions.="<OPTION VALUE=\"".$c->countryID."\">".$c->countryName."";

}

 

/////////////////////////////////////////////////////////////////

// INVOKE LIST LANGUAGES API TO POPULATE LANGUAGE DROP DOWN LIST

/////////////////////////////////////////////////////////////////

 

//BUILD URL FOR API CALL

$function = 'ListLanguages';

$url = 'https://api.web-portal.co/?customerID=8000003&key=6NbTmZw5LZdtTO8FuYH9G&function=ListLanguages';

 

//MAKE API CALL USING SIMPLE XML

$languagelist = simplexml_load_file($url);

 

foreach ($languagelist as $l)

{

$languageOptions.="<OPTION VALUE=\"".$l->languageID."\">".$l->languageName."";

}

 

/////////////////////////////////////////////////////////////////

// INVOKE LIST TIMEZONES API TO POPULATE TIMEZONE DROP DOWN LIST

/////////////////////////////////////////////////////////////////

 

//BUILD URL FOR API CALL

$function = 'ListTimezones';

$url = 'https://api.web-portal.co/?customerID=8000003&key=6NbTmZw5LZdtTO8FuYH9G&function=ListTimezones';

 

//MAKE API CALL USING SIMPLE XML

$timezonelist = simplexml_load_file($url);

 

foreach ($timezonelist as $t)

{

$timezoneOptions.="<OPTION VALUE=\"".$t->timezoneID."\">".$t->timezoneName."";

}

}

?>

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

<title>Untitled Document</title>

</head>

 

<body>

<p>NEW CLIENT SIGN UP</p>

<form id="NewClientForm" name="NewClientForm" method="post" action="NewClientForm.php">

  <p>Company Name:<br />

    <label for="company"></label>

  <input type="text" name="company" id="company" value="<? echo $company; ?>" />

  </p>

  <p>Address 1:<br />

    <label for="address1"></label>

    <input type="text" name="address1" id="address1" value="<? echo $address1; ?>" />

  </p>

  <p>Address 2:<br />

    <label for="address2"></label>

    <input type="text" name="address2" id="address2" value="<? echo $address2; ?>" />

  </p>

  <p>City:<br />

    <label for="city"></label>

    <input type="text" name="city" id="city" value="<? echo $city; ?>" />

  </p>

  <p>State/Province:<br />

    <label for="state"></label>

    <input type="text" name="state" id="state" value="<? echo $state; ?>" />

  </p>

  <p>Zip/Postal Code:<br />

    <label for="postal"></label>

    <input type="text" name="postal" id="postal" value="<? echo $postal; ?>" />

  </p>

  <p>Country:<br />

    <label for="country"></label>

    <select name="country" id="country">

    <? echo $countryOptions; ?>

    </select>

  </p>

  <p>Primary Contact First Name:<br />

    <label for="firstname"></label>

    <input type="text" name="firstname" id="firstname" value="<? echo $firstname; ?>" />

  </p>

  <p>Primary Contact Last Name:<br />

    <label for="lastname"></label>

    <input type="text" name="lastname" id="lastname" value="<? echo $lastname; ?>" />

  </p>

  <p>Primary Contact Telephone:<br />

    <label for="phone"></label>

    <input type="text" name="phone" id="phone" value="<? echo $phone; ?>" />

  </p>

  <p>Primary Contact Email:<br />

    <label for="email"></label>

    <input type="text" name="email" id="email" value="<? echo $email; ?>" />

  </p>

  <p>Account Type:<br />

    <input type="radio" name="type" id="acb" value="ACB" />

    <label for="acb">ACB</label>

    <input type="radio" name="type" id="obm" value="OBM" />

    <label for="obm">OBM</label>

  </p>

  <p>Preferred Username:<br />

    <label for="username"></label>

    <input type="text" name="username" id="username" value="<? echo $username; ?>" />

  </p>

  <p>Alias/Nickname:<br />

    <label for="alias"></label>

    <input type="text" name="alias" id="alias" value="<? echo $alias; ?>" />

  </p>

  <p>Language:<br />

    <label for="language"></label>

    <select name="language" id="language">

    <? echo $languageOptions; ?>

    </select>

  </p>

  <p>Timezone:<br />

    <label for="timezone"></label>

    <select name="timezone" id="timezone">

    <? echo $timezoneOptions; ?>

    </select>

  </p>

  <p> </p>

  <p>

    <input type="submit" name="submit" id="submit" value="Sign Up" />

  </p>

</form>

<p><br />

</p>

</body>

</html>

 

The following errors are produced...

 

http://cubetech.com.au/downloads/signup.php

 

Can please confirm my suspicions of simplexml_load_file() are not permitted. I have been reading about cURL implementation instead can someone provide some assistance if this is possible and assist.

 

A lot of thank in advance,

 

Andrew Chapman

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.