I have set up the Web To Lead form to integrate with my site's quote request function, but the ReturnURL doesn't work and any code after the form is sent doesn't seem to render. I know this isn't the standard CRM code, but could someone look at it and let me know why this problem might be occuring?
PS: The data goes onto the CRM perfectly, it's just that the user doesn't see that the form's been submitted, which results in them re-submitting a few times and then getting irritated, thinking it doesn't work.
The code is as follows (I've xxx'ed out form IDs to prevent any malicious intent:
// Send data to Zoho CRM
function do_post_request($url, $postdata)
{
$content = "";
// Add post data to request.
foreach($postdata as $key => $value)
{
$content .= "{$key}={$value}&";
}
$params = array('http' => array(
'method' => 'POST',
'header' => 'Content-Type: application/x-www-form-urlencoded',
'content' => $content
));
$ctx = stream_context_create($params);
$fp = fopen($url, 'rb', false, $ctx);
if (!$fp) {
throw new Exception("Connection problem, {$php_errormsg}");
}
$response = @stream_get_contents($fp);
if ($response === false) {
throw new Exception("Response error, {$php_errormsg}");
}
return $response;
}
$descr = "Quote Message: " . $message;
// Post variables.
$postdata = array(
'xnQsjsdp' => 'xxxxxxxxxxxxx',
'zc_gad' => '',
'xmIwtLD' => 'xxxxxxxxxxxxxx-xxxxxxxxxxx',
'actionType' => 'TGVhZHM=',
'returnURL' => '',
'Company' => $quote_company,
'First Name' => $quote_name,
'Last Name' => $quote_name,
'Email' => $quote_email,
'Phone' => $quote_tel,
'Website' => $quote_website,
'Lead Source' => 'Web Research',
'Description' => $descr
);
do_post_request("https://crm.zoho.com/crm/WebToLeadForm", $postdata);