Hi all,
I feel like I'm just missing something simple here.
The following code is a basic form page that works perfectly to create a lead in SugarCRM.
<?php
//if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
//the if statement above always dies - sugar forum recommends the line below
$GLOBALS['sugarEntry'] = true;
?>
<form name='leadcap' action='http://crm.MYURL.com/SugarCE/index.php?entryPoint=leadCapture' method='post'>
<input type='hidden' name='user' value='override'>
Test Lead Input Form<br>
First Name: <input type='text' name='first_name'><br>
Last Name:<input type='text' name='last_name'><br>
Account Name:<input type='text' name='account_name'><br>
<input type='Submit' name='submit' value='Submit'>
</form>
I'm trying to get this functionality to work in RSFormPro. I found the following Silent Post method in the User Guide.
http://www.rsjoomla.com/index.php/rsformpro.scripts.silent-post/Silent-Post.html
This seems to be a possible solution for me. However, I can't seem to get the desired results.
I have tried putting the following into the \"Script called on form process \" area.
if(isset($_POST['form']['user'])){
// I needed the following line in my basic form do I need it here
// or does it make sense here?
$GLOBALS['sugarEntry'] = true;
$url = \"http://crm.MYURL.com/SugarCE/index.php?entryPoint=leadCapture\";
$useragent=\"YahooSeeker-Testing/v3.9 (compatible; Mozilla 4.0; MSIE 5.5; http://search.yahoo.com/)\";
$ch = curl_init();
curl_setopt($ch, CURLOPT_USERAGENT, $useragent);
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_POST, 1);
// HERE YOU MUST SET THE VARIABLES FROM THE FORM
curl_setopt($ch, CURLOPT_POSTFIELDS,\"user=\".$_POST['form']['user']);
curl_setopt($ch, CURLOPT_POSTFIELDS,\"first_name=\".$_POST['form']['first_name']);
curl_setopt($ch, CURLOPT_POSTFIELDS,\"last_name=\".$_POST['form']['last_name']);
curl_setopt($ch, CURLOPT_POSTFIELDS,\"account_name=\".$_POST['form']['account_name']);
// execute curl,fetch the result and close curl connection
$result= curl_exec ($ch);
curl_close ($ch);
}
The form displays and submits, shows up in email, etc. However, it does not insert a lead into SugarCRM like my basic form does.
- Am I referencing the Fields incorrectly?
- Or maybe I need to do something else with the following line that was necessary in my basic form, I'm not sure if I can place it into the curl piece like I'm trying to??
$GLOBALS = true;
To note:
I do have my RSForm setup with a hidden field Name=user and Default Value=override to make it match the input like the the basic form at the top of this post.
I have first_name, last_name, and account_name setup as textboxes as well.
Any help would be greatly appreciated.
Thanks<br><br>Post edited by: jgamma, at: 2008/11/25 11:09