Receive Post data from XML and then post to mysql using php

I'm comfortable with using perl,html,some php but this is my first time trying to receive data via http_post. I have a crm system (vtiger) that i need to create a new lead from a data source who deliver it in real time using xml data and the POST method sent via a ssl link i provide.

I'm so confused right now. Can anyone help me, i do so much better at breaking down code and figuring it out than working from scratch.

The data comes in the following format:

<?xml version="1.0" encoding="UTF-8"?>
<Leads xmlns="http://leads.leads.leads/hla/2006">
<Lead>
<LeadType>2</LeadType>
<LeadID>126728954</LeadID>
<DateCreated>2003-07-31T11:40:56</DateCreated>
<FirstName>first</FirstName>
<LastName>last</LastName>
<Email>test@nowhere.com</Email>

alxmrtAsked:
Who is Participating?
 
Ray PaseurConnect With a Mentor Commented:
When data is posted to a PHP script, it arrives in the superglobal array called $_POST.  Superglobal means that the array exists in all namespace and variable scopes, inside classes and functions, etc.

You can see the contents of $_POST with this code (try it in your own script):
echo "<pre>"; // MAKES IT EASY TO READ
var_dump($_POST);
echo "</pre>";

The XML you have posted above is not valid - the <Lead> tag is not closed.  If we fix it up we can show what the information looks like.  Check this script, here:
http://www.laprbass.com/RAY_temp_alxmrt.php
<?php // RAY_temp_alxmrt.php
error_reporting(E_ALL);
date_default_timezone_set('America/New_York');
echo "<pre>";

// THE XML STRING IN HEREDOC NOTATION
$ick = <<<ENDXML
<?xml version="1.0" encoding="UTF-8"?>
<Leads xmlns="http://leads.leads.leads/hla/2006">
<Lead>
<LeadType>2</LeadType>
<LeadID>126728954</LeadID>
<DateCreated>2003-07-31T11:40:56</DateCreated>
<FirstName>first</FirstName>
<LastName>last</LastName>
<Email>test@nowhere.com</Email>
ENDXML;

// THE REQUIRED CLOSING TAGS
$fix = <<<ENDFIX
</Lead>
</Leads>
ENDFIX;

// THE CORRECTED STRING
$xml = $ick . $fix;

// SHOW THE STRING
echo htmlentities($xml);
echo PHP_EOL;

// CONVERT XML TO AN OBJECT
$obj = SimpleXML_Load_String($xml);

// ACTIVATE THIS TO VISUALIZE THE OBJECT
var_dump($obj);

// USE AN ITERATOR TO ACCESS PROPERTIES OF THE OBJECT
foreach ($obj->Lead as $thing);
{
    $t = $thing->LeadType;
    $i = $thing->LeadID;
    $f = $thing->FirstName;
    echo "<br/>LeadType=$t LeadID=$i FirstName=$f";
}

Open in new window

0
 
alxmrtAuthor Commented:
Ray,

Thank you i'm looking over this now, i can see how the code is assigning the variables etc now thank you so much. The one bit i am still confused on is the connection from their server? how does the script know to listen for the xml data?

Thank you again you have already been a huge help

Alex
0
 
Ray PaseurCommented:
Great question.  Are you going to be receiving "raw post data" or will this XML come to you via a conventional HTTP post?  I ask because the way you read the data is slightly different.  With conventional HTTP post, the data arrives in an array, and with the raw post data, the data arrives in a string, and you have to parse it.  Your data source would almost certainly know which it is, and would be able to provide some test data.

Check with them and post back here.  While you do that I will look for an example of reading raw post data.
0
Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

 
Ray PaseurCommented:
Found an example here:
http://www.laprbass.com/RAY_raw_post_example.php
<?php // RAY_raw_post_example.php
error_reporting(E_ALL);
echo "<pre>"; // MAKE IT EASY TO READ



// THIS ILLUSTRATES THE USE OF RAW POST DATA, INSTEAD OF $_POST
// WHEN THE FORM TAG CONTAINS THE ATTRIBUTE enctype="text/plain"
// MAN PAGE http://www.w3.org/TR/html401/interact/forms.html



echo PHP_EOL . "_POST DATA FOLLOWS: ";
var_dump($_POST);

echo PHP_EOL . "RAW POST DATA FOLLOWS: ";
echo htmlentities($HTTP_RAW_POST_DATA);

echo PHP_EOL . "PHP INPUT FOLLOWS: ";
$input = @file_get_contents("php://input");
echo PHP_EOL . htmlentities($input);

// PARSE THE RAW POST DATA (THIS MAY NOT WORK RIGHT)
if (!empty($HTTP_RAW_POST_DATA))
{
    $post  = array();
    $pairs = explode(PHP_EOL, trim($HTTP_RAW_POST_DATA));
    foreach ($pairs as $pair)
    {
        $arr = explode('=', $pair, 2);
        $post[urldecode($arr[0])] = trim(urldecode($arr[1]));
    }
    echo PHP_EOL . "PARSED RAW POST DATA FOLLOWS: ";
    var_dump($post);
}
else
{
    echo PHP_EOL . "HTTP_RAW_POST_DATA IS EMPTY";
}

// PARSE THE PHP INPUT STREAM - WORKS IF NO enctype ATTR
if (!empty($input))
{
    $post  = array();
    $pairs = explode('&', trim($input));
    foreach ($pairs as $pair)
    {
        $arr = explode('=', $pair, 2);
        $post[urldecode($arr[0])] = trim(urldecode($arr[1]));
    }
    echo PHP_EOL . "PARSED PHP://INPUT FOLLOWS: ";
    var_dump($post);
}
else
{
    echo PHP_EOL . "PHP://INPUT IS EMPTY";
}


// THIS IS THE FORM SCRIPT - FOR CONVENIENCE WE DROP OUT OF PHP INTO HTML
?>
<form method="post" enctype="text/plain">
THIS FORM USES enctype="text/plain"
TYPE SOMETHING HERE:
<input type="text"   name="my_text" />
<input type="submit" name="my_butn" value="ENCTYPE TEXT/PLAIN" />
</form>

<form method="post">
THIS FORM USES NO enctype ATTRIBUTE
TYPE SOMETHING HERE:
<input type="text"   name="no_enctype_text" />
<input type="submit" name="no_enctype_butn" value="DEFAULT ENCTYPE" />
</form>

Open in new window

0
 
alxmrtAuthor Commented:
i received this from them:

XML - We post leads to a web server by including the XML data in the request stream itself. There are no variables (Post or otherwise) that hold the XML data.



Thanks again Ray
0
 
alxmrtAuthor Commented:
It is received as RAW data.
0
 
Ray PaseurCommented:
Then it will probably show up in $HTTP_RAW_POST_DATA or in "stdin" which is accessed this way:
$input = file_get_contents("php://input");
0
 
alxmrtAuthor Commented:
Ray,

This is what i have so far, i think i have it right? i'm not sure how to pass these variables to vtigercrm via webservices.



<?php // RAY_raw_post_example.php
error_reporting(E_ALL);
echo "<pre>"; // MAKE IT EASY TO READ



// THIS ILLUSTRATES THE USE OF RAW POST DATA, INSTEAD OF $_POST
// WHEN THE FORM TAG CONTAINS THE ATTRIBUTE enctype="text/plain"
// MAN PAGE http://www.w3.org/TR/html401/interact/forms.html

$input = @file_get_contents("php://input");

// PARSE THE RAW POST DATA (THIS MAY NOT WORK RIGHT)
if (!empty($HTTP_RAW_POST_DATA))
{
    $post  = array();
    $pairs = explode(PHP_EOL, trim($HTTP_RAW_POST_DATA));
    foreach ($pairs as $pair)
    {
        $arr = explode('=', $pair, 2);
        $post[urldecode($arr[0])] = trim(urldecode($arr[1]));
    }
}
else
{
    echo PHP_EOL . "HTTP_RAW_POST_DATA IS EMPTY";
}

// PARSE THE PHP INPUT STREAM - WORKS IF NO enctype ATTR
if (!empty($input))
{
    $post  = array();
    $pairs = explode('&', trim($input));
    foreach ($pairs as $pair)
    {
        $arr = explode('=', $pair, 2);
        $post[urldecode($arr[0])] = trim(urldecode($arr[1]));
    }
    echo PHP_EOL . "PARSED PHP://INPUT FOLLOWS: ";
    var_dump($post);
}
else
{
    echo PHP_EOL . "PHP://INPUT IS EMPTY";
}


// CONVERT XML TO AN OBJECT
$obj = SimpleXML_Load_String($xml);

// ACTIVATE THIS TO VISUALIZE THE OBJECT
var_dump($obj);

// USE AN ITERATOR TO ACCESS PROPERTIES OF THE OBJECT
foreach ($obj->Lead as $thing);
{
    $Leadtype = $thing->LeadType;
    $LeadID = $thing->LeadID;
    $firstname = $thing->FirstName;
    $lastname = $thing->LastName;
    $email = $thing->Email;
    $ssn = $thing->SSN;
    $maritalstatus = $thing->MaritalStatus;
    $spousefirst = $thing->SpouseFirstName;
    $spouselast = $thing->SpouseLastName;
    $street = $thing->MailStreetAddress;
    $city = $thing->MailCity;
    $state = $thing->MailState;
    $zip = $thing->MailZip;
    $dob = $thing->BirthDate;
    $grossmonthly = $thing->GrossMonthlyIncome;
    $occupationalstatus = $thing->OccupationalStatus;
    $employername = $thing->EmployerName;
    $employmentlength = $thing->EmploymentLength;
    $coborrowerfirst = $thing->B2_FirstName;
    $coborrowerlast = $thing->B2_LastName;
    $coborrowerssn = $thing->B2_SSN;
    $coborrowerstreet = $thing->B2_MailStreetAddress;
    $coborrowercity = $thing->B2_MailCity;
    $coborrowerstate = $thing->B2_MailState;
    $coborrowerzip = $thing->B2_MailZipCode;
    $coborrowerdob = $thing->B2_BirthDate;
    $coborrowerincome = $thing->B2_GrossMonthlyIncome;
    $phone = $thing->Phone1;
    $mobile = $thing->Phone2;
    $creditprofile = $thing->CreditProfile;
    $monthlydebt = $thing->MonthlyDebtPayments;
    $desiredloanamount = $thing->DesiredLoanAmount;
    $existingvalue = $thing->ExistingPropertyValue;
    $newvalue = $thing->NewPropertyValue;
    $propertyfound = $thing->PropertyFound;
    $intendeduse = $thing->IntendedPropertyUse;
    $propertystreet = $thing->StreetAddress;
    $propertycity = $thing->City;
    $propertystate = $thing->State;
    $propertyzip = $thing->ZipCode;
    $propertydescription = $thing->PropertyDescription;
    $firstmortgagebalance = $thing->FirstMortgageBalance;
    $firstmortgagerate = $thing->FirstMortgageInterestRate;
    $secondmortgagebalance = $thing->SecondMortgageBalance;
    $secondmortgagerate = $thing->SecondMortgageInterestRate;
    $desiredratetype = $thing->DesiredRateType;
    $desiredmonthlypayment = $thing->DesiredMonthlyPayment;
    $firstmortgageratetype = $thing->FirstMortgageRateType;
    $currentneed = $thing->CurrentNeedSituation;
    $loanpurpose = $thing->LoanPurpose;
    $loantype = $thing->LoanType;
    $preferredloantype = $thing->PreferredLoanType;
    $loantimeframe = $thing->LoanTimeFrame;
    $downpayment = $thing->DownPayment;
    $bankruptcy = $thing->Bankruptcy;
    $bankruptcytype = $thing->BankruptcyType;
    $ipaddress = $thing->IPAddress;
    $firsttimebuyer = $thing->FirstTimeBuyer;
    $homeowner = $thing->HomeOwner;
    $needpurchasereagent = $thing->NeedPurchaseREAgent;
    $reagentname = $thing->REAgentName;
    $reagentphone = $thing->REAgentPhone;
    $needsellingreagent = $thing->NeedSellingREAgent;
    $consumercomments = $thing->ConsumerComments;
    $additionalinformation = $thing->AdditionalInformation;


}

Open in new window

0
 
Ray PaseurCommented:
Make a Google search for "pass variables to vtigercrm" -- I am not sure how to do this either, but there seem to be some forums with that exact question in play.  This link looked especially promising:
http://wiki.vtiger.com/index.php/Developers_How_To%27s
0
 
alxmrtAuthor Commented:
how does my code look so far?
0
 
Ray PaseurCommented:
I don't know - I'm not really competent to evaluate others' code.  You might try running it in a test environment and using var_dump() to visualize the variables.  That will tell you a lot about what the code is doing to the data.
0
 
alxmrtAuthor Commented:
Ray you have been awesome so far thank you for all your help. So i have the data coming in as i can see in the below output that it is parsing it ok but then it throws an error when i try to assign the variable...any ideas, output is below and code that i have put together. The details within the output are all false i.e. no personal information this was just a test send.

Thanks
{URL:}
https://www.streamingvoip.com/lmb.php
{CONTENT:}
B2_MailCity:
REAgentPhone:
FirstMortgageBalance:130000
FirstName:Doutzen
EmployerName:Microsoft Inc.
AdditionalInformation:37.00
SearchZipCode:
PropertyCounty:Los Angeles
BankruptcyType:
SSN:234-34-2356
Email:Darwintrial3@lead.com
Phone1Type:HOME
StreetAddress:54321 Oxnard St.
ContactTime:
LeadType:2
LoanPurpose:Convert To Fixed Rate
B2_MailStreetAddress:
PropertyPurchasedYear:2004
BirthDate:
DateCreated:2007-12-11T17:00:42
PropertyState:CA
SecondMortgageInterestRate:
GrossMonthlyIncome:0
MonthlyDebtPayments:
MailState:CA
B2_LastName:
MailCity:Granada Hills
MailStreetAddress:889 Binder Lane
B2_SSN:
CreditProfile:Good
FirstMortgageInterestRate:6
WorkPhoneExt2:
B2_GrossMonthlyIncome:0
WorkPhoneExt1:
IPAddress:208.292.43.77
FirstMortgageRateType:
MaritalStatus:
B2_FirstName:
NeedPurchaseREAgent:
LoanType:Home Refinance
NeedSellingREAgent:
DesiredLoanAmount:200000
SpouseLastName:
DesiredRateType:
LeadID:113224533
HomeOwner:
ExistingPropertyValue:325000
Phone2:8052318760
Phone1:8052318761
EmploymentLength:More than 5 years
MailZipCode:91344
ConsumerComments:
B2_BirthDate:
LastName:Kroes
SpouseFirstName:
SecondMortgageBalance:0
B2_MailState:
City:Woodland Hills
DesiredMonthlyPayment:
Bankruptcy:No
REAgentName:
PropertyDescription:Multi Family
OccupationalStatus:Employed
ZipCode:91367
FirstTimeBuyer:
LoanTimeframe:2 months
B2_MailZipCode:
IntendedPropertyUse:Second / Vacation Home
DownPayment:
PreferredLoanType:
NewPropertyValue:
State:CA
Phone2Type:Cell
PropertyFound:
CurrentNeedSituation:

{RESPONSE:}
<pre>HTTP_RAW_POST_DATA IS EMPTYPARSED PHP://INPUT FOLLOWS: array(75) {  ["B2_MailCity"]=>  string(0) ""  ["REAgentPhone"]=>  string(0) ""  ["FirstMortgageBalance"]=>  string(6) "130000"  ["FirstName"]=>  string(7) "Doutzen"  ["EmployerName"]=>  string(14) "Microsoft Inc."  ["AdditionalInformation"]=>  string(5) "37.00"  ["SearchZipCode"]=>  string(0) ""  ["PropertyCounty"]=>  string(11) "Los Angeles"  ["BankruptcyType"]=>  string(0) ""  ["SSN"]=>  string(11) "234-34-2356"  ["Email"]=>  string(21) "Darwintrial3@lead.com"  ["Phone1Type"]=>  string(4) "HOME"  ["StreetAddress"]=>  string(16) "54321 Oxnard St."  ["ContactTime"]=>  string(0) ""  ["LeadType"]=>  string(1) "2"  ["LoanPurpose"]=>  string(21) "Convert To Fixed Rate"  ["B2_MailStreetAddress"]=>  string(0) ""  ["PropertyPurchasedYear"]=>  string(4) "2004"  ["BirthDate"]=>  string(0) ""  ["DateCreated"]=>  string(19) "2007-12-11T17:00:42"  ["PropertyState"]=>  string(2) "CA"  ["SecondMortgageInterestRate"]=>  string(0) ""  ["GrossMonthlyIncome"]=>  string(1) "0"  ["MonthlyDebtPayments"]=>  string(0) ""  ["MailState"]=>  string(2) "CA"  ["B2_LastName"]=>  string(0) ""  ["MailCity"]=>  string(13) "Granada Hills"  ["MailStreetAddress"]=>  string(15) "889 Binder Lane"  ["B2_SSN"]=>  string(0) ""  ["CreditProfile"]=>  string(4) "Good"  ["FirstMortgageInterestRate"]=>  string(1) "6"  ["WorkPhoneExt2"]=>  string(0) ""  ["B2_GrossMonthlyIncome"]=>  string(1) "0"  ["WorkPhoneExt1"]=>  string(0) ""  ["IPAddress"]=>  string(13) "208.292.43.77"  ["FirstMortgageRateType"]=>  string(0) ""  ["MaritalStatus"]=>  string(0) ""  ["B2_FirstName"]=>  string(0) ""  ["NeedPurchaseREAgent"]=>  string(0) ""  ["LoanType"]=>  string(14) "Home Refinance"  ["NeedSellingREAgent"]=>  string(0) ""  ["DesiredLoanAmount"]=>  string(6) "200000"  ["SpouseLastName"]=>  string(0) ""  ["DesiredRateType"]=>  string(0) ""  ["LeadID"]=>  string(9) "113224533"  ["HomeOwner"]=>  string(0) ""  ["ExistingPropertyValue"]=>  string(6) "325000"  ["Phone2"]=>  string(10) "8052318760"  ["Phone1"]=>  string(10) "8052318761"  ["EmploymentLength"]=>  string(17) "More than 5 years"  ["MailZipCode"]=>  string(5) "91344"  ["ConsumerComments"]=>  string(0) ""  ["B2_BirthDate"]=>  string(0) ""  ["LastName"]=>  string(5) "Kroes"  ["SpouseFirstName"]=>  string(0) ""  ["SecondMortgageBalance"]=>  string(1) "0"  ["B2_MailState"]=>  string(0) ""  ["City"]=>  string(14) "Woodland Hills"  ["DesiredMonthlyPayment"]=>  string(0) ""  ["Bankruptcy"]=>  string(2) "No"  ["REAgentName"]=>  string(0) ""  ["PropertyDescription"]=>  string(12) "Multi Family"  ["OccupationalStatus"]=>  string(8) "Employed"  ["ZipCode"]=>  string(5) "91367"  ["FirstTimeBuyer"]=>  string(0) ""  ["LoanTimeframe"]=>  string(8) "2 months"  ["B2_MailZipCode"]=>  string(0) ""  ["IntendedPropertyUse"]=>  string(22) "Second / Vacation Home"  ["DownPayment"]=>  string(0) ""  ["PreferredLoanType"]=>  string(0) ""  ["NewPropertyValue"]=>  string(0) ""  ["State"]=>  string(2) "CA"  ["Phone2Type"]=>  string(4) "Cell"  ["PropertyFound"]=>  string(0) ""  ["CurrentNeedSituation"]=>  string(0) ""}Notice: Undefined variable: xml in /var/www-ssl/lmb.php on line 49bool(false)Notice: Trying to get property of non-object in /var/www-ssl/lmb.php on line 55Warning: Invalid argument supplied for foreach() in /var/www-ssl/lmb.php on line 55Notice: Undefined variable: thing in /var/www-ssl/lmb.php on line 57Notice: Trying to get property of non-object in /var/www-ssl/lmb.php on line 57Notice: Undefined variable: thing in /var/www-ssl/lmb.php on line 58Notice: Trying to get property of non-object in /var/www-ssl/lmb.php on line 58Notice: Undefined variable: thing in /var/www-ssl/lmb.php on line 59Notice: Trying to get property of non-object in /var/www-ssl/lmb.php on line 59Notice: Undefined variable: thing in /var/www-ssl/lmb.php on line 60Notice: Trying to get property of non-object in /var/www-ssl/lmb.php on line 60Notice: Undefined variable: thing in /var/www-ssl/lmb.php on line 61Notice: Trying to get property of non-object in /var/www-ssl/lmb.php on line 61Notice: Undefined variable: thing in /var/www-ssl/lmb.php on line 62Notice: Trying to get property of non-object in /var/www-ssl/lmb.php on line 62Notice: Undefined variable: thing in /var/www-ssl/lmb.php on line 63Notice: Trying to get property of non-object in /var/www-ssl/lmb.php on line 63Notice: Undefined variable: thing in /var/www-ssl/lmb.php on line 64Notice: Trying to get property of non-object in /var/www-ssl/lmb.php on line 64Notice: Undefined variable: thing in /var/www-ssl/lmb.php on line 65Notice: Trying to get property of non-object in /var/www-ssl/lmb.php on line 65Notice: Undefined variable: thing in /var/www-ssl/lmb.php on line 66Notice: Trying to get property of non-object in /var/www-ssl/lmb.php on line 66Notice: Undefined variable: thing in /var/www-ssl/lmb.php on line 67Notice: Trying to get property of non-object in /var/www-ssl/lmb.php on line 67Notice: Undefined variable: thing in /var/www-ssl/lmb.php on line 68Notice: Trying to get property of non-object in /var/www-ssl/lmb.php on line 68Notice: Undefined variable: thing in /var/www-ssl/lmb.php on line 69Notice: Trying to get property of non-object in /var/www-ssl/lmb.php on line 69Notice: Undefined variable: thing in /var/www-ssl/lmb.php on line 70Notice: Trying to get property of non-object in /var/www-ssl/lmb.php on line 70Notice: Undefined variable: thing in /var/www-ssl/lmb.php on line 71Notice: Trying to get property of non-object in /var/www-ssl/lmb.php on line 71Notice: Undefined variable: thing in /var/www-ssl/lmb.php on line 72Notice: Trying to get property of non-object in /var/www-ssl/lmb.php on line 72Notice: Undefined variable: thing in /var/www-ssl/lmb.php on line 73Notice: Trying to get property of non-object in /var/www-ssl/lmb.php on line 73Notice: Undefined variable: thing in /var/www-ssl/lmb.php on line 74Notice: Trying to get property of non-object in /var/www-ssl/lmb.php on line 74Notice: Undefined variable: thing in /var/www-ssl/lmb.php on line 75Notice: Trying to get property of non-object in /var/www-ssl/lmb.php on line 75Notice: Undefined variable: thing in /var/www-ssl/lmb.php on line 76Notice: Trying to get property of non-object in /var/www-ssl/lmb.php on line 76Notice: Undefined variable: thing in /var/www-ssl/lmb.php on line 77Notice: Trying to get property of non-object in /var/www-ssl/lmb.php on line 77Notice: Undefined variable: thing in /var/www-ssl/lmb.php on line 78Notice: Trying to get property of non-object in /var/www-ssl/lmb.php on line 78Notice: Undefined variable: thing in /var/www-ssl/lmb.php on line 79Notice: Trying to get property of non-object in /var/www-ssl/lmb.php on line 79Notice: Undefined variable: thing in /var/www-ssl/lmb.php on line 80Notice: Trying to get property of non-object in /var/www-ssl/lmb.php on line 80Notice: Undefined variable: thing in /var/www-ssl/lmb.php on line 81Notice: Trying to get property of non-object in /var/www-ssl/lmb.php on line 81Notice: Undefined variable: thing in /var/www-ssl/lmb.php on line 82Notice: Trying to get property of non-object in /var/www-ssl/lmb.php on line 82Notice: Undefined variable: thing in /var/www-ssl/lmb.php on line 83Notice: Trying to get property of non-object in /var/www-ssl/lmb.php on line 83Notice: Undefined variable: thing in /var/www-ssl/lmb.php on line 84Notice: Trying to get property of non-object in /var/www-ssl/lmb.php on line 84Notice: Undefined variable: thing in /var/www-ssl/lmb.php on line 85Notice: Trying to get property of non-object in /var/www-ssl/lmb.php on line 85Notice: Undefined variable: thing in /var/www-ssl/lmb.php on line 86Notice: Trying to get property of non-object in /var/www-ssl/lmb.php on line 86Notice: Undefined variable: thing in /var/www-ssl/lmb.php on line 87Notice: Trying to get property of non-object in /var/www-ssl/lmb.php on line 87Notice: Undefined variable: thing in /var/www-ssl/lmb.php on line 88Notice: Trying to get property of non-object in /var/www-ssl/lmb.php on line 88Notice: Undefined variable: thing in /var/www-ssl/lmb.php on line 89Notice: Trying to get property of non-object in /var/www-ssl/lmb.php on line 89Notice: Undefined variable: thing in /var/www-ssl/lmb.php on line 90Notice: Trying to get property of non-object in /var/www-ssl/lmb.php on line 90Notice: Undefined variable: thing in /var/www-ssl/lmb.php on line 91Notice: Trying to get property of non-object in /var/www-ssl/lmb.php on line 91Notice: Undefined variable: thing in /var/www-ssl/lmb.php on line 92Notice: Trying to get property of non-object in /var/www-ssl/lmb.php on line 92Notice: Undefined variable: thing in /var/www-ssl/lmb.php on line 93Notice: Trying to get property of non-object in /var/www-ssl/lmb.php on line 93Notice: Undefined variable: thing in /var/www-ssl/lmb.php on line 94Notice: Trying to get property of non-object in /var/www-ssl/lmb.php on line 94Notice: Undefined variable: thing in /var/www-ssl/lmb.php on line 95Notice: Trying to get property of non-object in /var/www-ssl/lmb.php on line 95Notice: Undefined variable: thing in /var/www-ssl/lmb.php on line 96Notice: Trying to get property of non-object in /var/www-ssl/lmb.php on line 96Notice: Undefined variable: thing in /var/www-ssl/lmb.php on line 97Notice: Trying to get property of non-object in /var/www-ssl/lmb.php on line 97Notice: Undefined variable: thing in /var/www-ssl/lmb.php on line 98Notice: Trying to get property of non-object in /var/www-ssl/lmb.php on line 98Notice: Undefined variable: thing in /var/www-ssl/lmb.php on line 99Notice: Trying to get property of non-object in /var/www-ssl/lmb.php on line 99Notice: Undefined variable: thing in /var/www-ssl/lmb.php on line 100Notice: Trying to get property of non-object in /var/www-ssl/lmb.php on line 100Notice: Undefined variable: thing in /var/www-ssl/lmb.php on line 101Notice: Trying to get property of non-object in /var/www-ssl/lmb.php on line 101Notice: Undefined variable: thing in /var/www-ssl/lmb.php on line 102Notice: Trying to get property of non-object in /var/www-ssl/lmb.php on line 102Notice: Undefined variable: thing in /var/www-ssl/lmb.php on line 103Notice: Trying to get property of non-object in /var/www-ssl/lmb.php on line 103Notice: Undefined variable: thing in /var/www-ssl/lmb.php on line 104Notice: Trying to get property of non-object in /var/www-ssl/lmb.php on line 104Notice: Undefined variable: thing in /var/www-ssl/lmb.php on line 105Notice: Trying to get property of non-object in /var/www-ssl/lmb.php on line 105Notice: Undefined variable: thing in /var/www-ssl/lmb.php on line 106Notice: Trying to get property of non-object in /var/www-ssl/lmb.php on line 106Notice: Undefined variable: thing in /var/www-ssl/lmb.php on line 107Notice: Trying to get property of non-object in /var/www-ssl/lmb.php on line 107Notice: Undefined variable: thing in /var/www-ssl/lmb.php on line 108Notice: Trying to get property of non-object in /var/www-ssl/lmb.php on line 108Notice: Undefined variable: thing in /var/www-ssl/lmb.php on line 109Notice: Trying to get property of non-object in /var/www-ssl/lmb.php on line 109Notice: Undefined variable: thing in /var/www-ssl/lmb.php on line 110Notice: Trying to get property of non-object in /var/www-ssl/lmb.php on line 110Notice: Undefined variable: thing in /var/www-ssl/lmb.php on line 111Notice: Trying to get property of non-object in /var/www-ssl/lmb.php on line 111Notice: Undefined variable: thing in /var/www-ssl/lmb.php on line 112Notice: Trying to get property of non-object in /var/www-ssl/lmb.php on line 112Notice: Undefined variable: thing in /var/www-ssl/lmb.php on line 113Notice: Trying to get property of non-object in /var/www-ssl/lmb.php on line 113Notice: Undefined variable: thing in /var/www-ssl/lmb.php on line 114Notice: Trying to get property of non-object in /var/www-ssl/lmb.php on line 114Notice: Undefined variable: thing in /var/www-ssl/lmb.php on line 115Notice: Trying to get property of non-object in /var/www-ssl/lmb.php on line 115Notice: Undefined variable: thing in /var/www-ssl/lmb.php on line 116Notice: Trying to get property of non-object in /var/www-ssl/lmb.php on line 116Notice: Undefined variable: thing in /var/www-ssl/lmb.php on line 117Notice: Trying to get property of non-object in /var/www-ssl/lmb.php on line 117Notice: Undefined variable: thing in /var/www-ssl/lmb.php on line 118Notice: Trying to get property of non-object in /var/www-ssl/lmb.php on line 118Notice: Undefined variable: thing in /var/www-ssl/lmb.php on line 119Notice: Trying to get property of non-object in /var/www-ssl/lmb.php on line 119Notice: Undefined variable: thing in /var/www-ssl/lmb.php on line 120Notice: Trying to get property of non-object in /var/www-ssl/lmb.php on line 120Notice: Undefined variable: thing in /var/www-ssl/lmb.php on line 121Notice: Trying to get property of non-object in /var/www-ssl/lmb.php on line 121Warning: require_once(config.php): failed to open stream: No such file or directory in /var/www-ssl/lmb.php on line 138Fatal error: require_once(): Failed opening required 'config.php' (include_path='.:/usr/share/php:/usr/share/pear') in /var/www-ssl/lmb.php on line 138

Open in new window

<?php //
error_reporting(E_ALL);
echo "<pre>"; // MAKE IT EASY TO READ



// THIS ILLUSTRATES THE USE OF RAW POST DATA, INSTEAD OF $_POST
// WHEN THE FORM TAG CONTAINS THE ATTRIBUTE enctype="text/plain"
// MAN PAGE http://www.w3.org/TR/html401/interact/forms.html

$input = @file_get_contents("php://input");

// PARSE THE PHP INPUT STREAM - WORKS IF NO enctype ATTR
if (!empty($input))
{
    $post  = array();
    $pairs = explode('&', trim($input));
    foreach ($pairs as $pair)
    {
        $arr = explode('=', $pair, 2);
        $post[urldecode($arr[0])] = trim(urldecode($arr[1]));
    }
    echo PHP_EOL . "PARSED PHP://INPUT FOLLOWS: ";
    var_dump($post);
}
else
{
    echo PHP_EOL . "PHP://INPUT IS EMPTY";
}


// CONVERT XML TO AN OBJECT
$obj = SimpleXML_Load_String($xml);

// ACTIVATE THIS TO VISUALIZE THE OBJECT
var_dump($obj);

// USE AN ITERATOR TO ACCESS PROPERTIES OF THE OBJECT
foreach ($obj->Lead as $thing);
{
    $Leadtype = $thing->LeadType;
    $LeadID = $thing->LeadID;
    $firstname = $thing->FirstName;
    $lastname = $thing->LastName;
    $email = $thing->Email;
    $ssn = $thing->SSN;
    $maritalstatus = $thing->MaritalStatus;
    $spousefirst = $thing->SpouseFirstName;
    $spouselast = $thing->SpouseLastName;
    $street = $thing->MailStreetAddress;

 $city = $thing->MailCity;
    $state = $thing->MailState;
    $zip = $thing->MailZip;
    $dob = $thing->BirthDate;
    $grossmonthly = $thing->GrossMonthlyIncome;
    $occupationalstatus = $thing->OccupationalStatus;
    $employername = $thing->EmployerName;
    $employmentlength = $thing->EmploymentLength;
    $coborrowerfirst = $thing->B2_FirstName;
    $coborrowerlast = $thing->B2_LastName;
    $coborrowerssn = $thing->B2_SSN;
    $coborrowerstreet = $thing->B2_MailStreetAddress;
    $coborrowercity = $thing->B2_MailCity;
    $coborrowerstate = $thing->B2_MailState;
    $coborrowerzip = $thing->B2_MailZipCode;
    $coborrowerdob = $thing->B2_BirthDate;
    $coborrowerincome = $thing->B2_GrossMonthlyIncome;
    $phone = $thing->Phone1;
    $mobile = $thing->Phone2;
    $creditprofile = $thing->CreditProfile;
    $monthlydebt = $thing->MonthlyDebtPayments;
    $desiredloanamount = $thing->DesiredLoanAmount;
    $existingvalue = $thing->ExistingPropertyValue;
    $newvalue = $thing->NewPropertyValue;
    $propertyfound = $thing->PropertyFound;
    $intendeduse = $thing->IntendedPropertyUse;
    $propertystreet = $thing->StreetAddress;
    $propertycity = $thing->City;
    $propertystate = $thing->State;
    $propertyzip = $thing->ZipCode;
    $propertydescription = $thing->PropertyDescription;
    $firstmortgagebalance = $thing->FirstMortgageBalance;
    $firstmortgagerate = $thing->FirstMortgageInterestRate;
    $secondmortgagebalance = $thing->SecondMortgageBalance;
    $secondmortgagerate = $thing->SecondMortgageInterestRate;
    $desiredratetype = $thing->DesiredRateType;
    $desiredmonthlypayment = $thing->DesiredMonthlyPayment;
    $firstmortgageratetype = $thing->FirstMortgageRateType;
    $currentneed = $thing->CurrentNeedSituation;
    $loanpurpose = $thing->LoanPurpose;
    $loantype = $thing->LoanType;
    $preferredloantype = $thing->PreferredLoanType;
    $loantimeframe = $thing->LoanTimeFrame;
    $downpayment = $thing->DownPayment;
    $bankruptcy = $thing->Bankruptcy;
    $bankruptcytype = $thing->BankruptcyType;
    $ipaddress = $thing->IPAddress;
    $firsttimebuyer = $thing->FirstTimeBuyer;
  $homeowner = $thing->HomeOwner;
    $needpurchasereagent = $thing->NeedPurchaseREAgent;
    $reagentname = $thing->REAgentName;
    $reagentphone = $thing->REAgentPhone;
    $needsellingreagent = $thing->NeedSellingREAgent;
    $consumercomments = $thing->ConsumerComments;
    $additionalinformation = $thing->AdditionalInformation;


}




/*+**********************************************************************************
 * The contents of this file are subject to the vtiger CRM Public License Version 1.0
 * ("License"); You may not use this file except in compliance with the License
 * The Original Code is:  vtiger CRM Open Source
 * The Initial Developer of the Original Code is vtiger.
 * Portions created by vtiger are Copyright (C) vtiger.
 * All Rights Reserved.
 ************************************************************************************/

require_once('config.php');

require_once('modules/Leads/Leads.php');
require_once('modules/Contacts/contactSeedData.php');
require_once('modules/Contacts/Contacts.php');
require_once('modules/Accounts/Accounts.php');
require_once('modules/Campaigns/Campaigns.php');
require_once('modules/Potentials/Potentials.php');
require_once('modules/Calendar/Activity.php');
require_once('include/database/PearDatabase.php');
require_once('include/utils/utils.php');
require_once('include/language/en_us.lang.php');
require_once('include/ComboStrings.php');
require_once('modules/Products/Products.php');
require_once('modules/PriceBooks/PriceBooks.php');
require_once('modules/Vendors/Vendors.php');
require_once('modules/Faq/Faq.php');
require_once('modules/HelpDesk/HelpDesk.php');
require_once('modules/Documents/Documents.php');
require_once('modules/Quotes/Quotes.php');
require_once('modules/SalesOrder/SalesOrder.php');
require_once('modules/PurchaseOrder/PurchaseOrder.php');
require_once('modules/Invoice/Invoice.php');
require_once('modules/Emails/Emails.php');

$adb = PearDatabase::getInstance();

// Assigned user for all demo data.
$assigned_user_name = "bill";

// Look up the user id for the assigned user
$seed_user = new Users();

$assigned_user_id = $seed_user->retrieve_user_id($assigned_user_name);

global $current_user;

$current_user = new Users();
$result = $current_user->retrieve_entity_info($assigned_user_id,'Users');

$tagkey = 1;


$company_count=0;
for($i=0; $i<10; $i++)
{
        $lead = new Leads();
        $lead->column_fields["firstname"] = $firstname;
        $lead->column_fields["lastname"] = $lastname;
        $lead->column_fields["assigned_user_id"] = $assigned_user_id;
        $lead->column_fields["email"] = $email;
        $lead->column_fields["phone"] = $phone();
        $lead->column_fields["mobile"] = $mobile();
        $lead->column_fields["lane"] = $street;
        $lead->column_fields["city"] = $city;
        $lead->column_fields["state"] = $state;
        $lead->column_fields["code"] = $zip;
        $lead->column_fields["country"] = 'USA';
        $lead->column_fields["leadsource"] = 'Lower My Bills SS#';
        $lead->column_fields["leadstatus"] = 'Attempting Contact';
        $lead->column_fields["cf_657"] = $ssn;
        $lead->column_fields["cf_608"] = $maritalstatus;
        $lead->column_fields["cf_615"] = $spousefirst;
        $lead->column_fields["cf_609"] = $spouselast;
        $lead->column_fields["cf_616"] = $dob;
        $lead->column_fields["cf_610"] = $grossmonthly;
        $lead->column_fields["cf_617"] = $occupationalstatus;
        $lead->column_fields["cf_611"] = $employername;
        $lead->column_fields["cf_660"] = $employmentlength;
        $lead->column_fields["cf_667"] = $coborrowerfirst;
        $lead->column_fields["cf_668"] = $coborrowerlast;
        $lead->column_fields["cf_673"] = $coborrowerssn;
        $lead->column_fields["cf_669"] = $coborrowerstreet;
 $lead->column_fields["cf_670"] = $coborrowercity;
        $lead->column_fields["cf_671"] = $coborrowerstate;
        $lead->column_fields["cf_672"] = $coborrowerzip;
        $lead->column_fields["cf_674"] = $coborrowerdob;
        $lead->column_fields["cf_675"] = $coborrowerincome;
        $lead->column_fields["cf_619"] = $creditprofile;
        $lead->column_fields["cf_620"] = $monthlydebt;
        $lead->column_fields["cf_665"] = $desiredloanamount;
        $lead->column_fields["cf_661"] = $existingvalue;
        $lead->column_fields["cf_662"] = $newvalue;
        $lead->column_fields["cf_630"] = $propertyfound;
        $lead->column_fields["cf_632"] = $intendeduse;
        $lead->column_fields["cf_633"] = $propertystreet;
        $lead->column_fields["cf_634"] = $propertycity;
        $lead->column_fields["cf_635"] = $propertystate;
        $lead->column_fields["cf_636"] = $propertyzip;
        $lead->column_fields["cf_638"] = $propertydescription;
        $lead->column_fields["cf_663"] = $firstmortgagebalance;
        $lead->column_fields["cf_641"] = $firstmortgagerate;
        $lead->column_fields["cf_664"] = $secondmortgagebalance;
        $lead->column_fields["cf_644"] = $secondmortgagerate;
        $lead->column_fields["cf_647"] = $desiredratetype;
        $lead->column_fields["cf_642"] = $firstmortgageratetype;
        $lead->column_fields["cf_648"] = $currentneed;
        $lead->column_fields["cf_649"] = $loanpurpose;
        $lead->column_fields["cf_650"] = $loantype;
        $lead->column_fields["cf_651"] = $preferredloantype;
        $lead->column_fields["cf_652"] = $loantimeframe;
        $lead->column_fields["cf_653"] = $downpayment;
        $lead->column_fields["cf_654"] = $bankruptcy;
        $lead->column_fields["cf_655"] = $homeowner;
        $lead->column_fields["description"] = $additionalinformation;
        $lead->save("Leads");
}

?>

Open in new window

0
 
Ray PaseurCommented:
Are you sure you don't want to hire a professional to give you a "leg up" on this problem?

Here is line 123 from the second code snippet:
require_once('config.php');

Here is part of the collected error messages:
Fatal error: require_once(): Failed opening required 'config.php' (include_path='.:/usr/share/php:/usr/share/pear') in /var/www-ssl/lmb.php on line 138

That tells me two things.  (1) the "config.php" file is not there; (2) the error message and the script do not match because 123 != 138.

Not sure what to tell you at this point, except that when I find myself deep in a debugging exercise with scripts and error messages that do not match up, I try to step back, check the URL paths (to make sure I am testing the right code) and maybe build a simple test case to prove my "proof of concept."  It's a process, not a question with an answer.  Best of luck with this, ~Ray
0
 
alxmrtAuthor Commented:
Awesome help Ray thank you so much. I have the script fully operational, i looked back at the code and i had moved the script so i had to remap the file locations.

Thank you so much for all your help!
0
 
Ray PaseurCommented:
Great - glad you've got it going and thanks for the points!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.