• gyung58
  • NEWBIE
  • 0 Points
  • Member since 2007

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 2
    Replies
I've been searching this for a long time, and I want to be able to send the web-to-lead form using PHP only.

Other people have been trying this, and I've been reading through all the comments, but still haven't been able to figure it out. Currently i'm still trying the fsockopen method. Salesforce said they would get back to me on it.... but they haven't. Anyway this is the script:

function sendToHost($host,$method,$path,$data,$useragent=0)
{
    // Supply a default method of GET if the one passed was empty
    if (empty($method)) {
        $method = 'GET';
    }
    $method = strtoupper($method);
    $fp = fsockopen($host, 80);
    if ($method == 'GET') {
        $path .= '?' . $data;
    }
    fputs($fp, "$method $path HTTP/1.1\r\n");
    fputs($fp, "Host: $host\r\n");
    fputs($fp,"Content-type: text/html; charset=UTF-8\r\n");
    fputs($fp, "Content-length: " . strlen($data) . "\r\n");
    if ($useragent) {
        fputs($fp, "User-Agent: MSIE\r\n");
    }
    fputs($fp, "Connection: close\r\n\r\n");
    if ($method == 'POST') {
        fputs($fp, $data);
    }

    while (!feof($fp)) {
        $buf .= fgets($fp,128);
    }
    fclose($fp);
    return $buf;
}

I've tried using it by sending arrays and strings in different formats, such as:

$info = 'oid=\"XXXXXXXXXXX\"' . '&';
$info .= 'retURL=\"XXXXXXXXXXXXXXX\"' . '&';
$info .= 'last_name=\"Yung\"' . '&';


w/o the escapes and also:

   'oid'         => 'oid=XXXXXXXXXXX',
   'retURL'      => 'retURL=XXXXXXXXXXXXXXX',
   'last_name'   => 'Yung',


etc.

I don't want to validate/submit forms with Javascript, and my other idea is having the user confirm the details and submit to salesforce using hidden fields (but spammers can thus clone the page and spam me) while keeping the data in sessions (haven't tested this yet). Anyhelp would REALLY be appreciated, thanks!
I've been searching this for a long time, and I want to be able to send the web-to-lead form using PHP only.

Other people have been trying this, and I've been reading through all the comments, but still haven't been able to figure it out. Currently i'm still trying the fsockopen method. Salesforce said they would get back to me on it.... but they haven't. Anyway this is the script:

function sendToHost($host,$method,$path,$data,$useragent=0)
{
    // Supply a default method of GET if the one passed was empty
    if (empty($method)) {
        $method = 'GET';
    }
    $method = strtoupper($method);
    $fp = fsockopen($host, 80);
    if ($method == 'GET') {
        $path .= '?' . $data;
    }
    fputs($fp, "$method $path HTTP/1.1\r\n");
    fputs($fp, "Host: $host\r\n");
    fputs($fp,"Content-type: text/html; charset=UTF-8\r\n");
    fputs($fp, "Content-length: " . strlen($data) . "\r\n");
    if ($useragent) {
        fputs($fp, "User-Agent: MSIE\r\n");
    }
    fputs($fp, "Connection: close\r\n\r\n");
    if ($method == 'POST') {
        fputs($fp, $data);
    }

    while (!feof($fp)) {
        $buf .= fgets($fp,128);
    }
    fclose($fp);
    return $buf;
}

I've tried using it by sending arrays and strings in different formats, such as:

$info = 'oid=\"XXXXXXXXXXX\"' . '&';
$info .= 'retURL=\"XXXXXXXXXXXXXXX\"' . '&';
$info .= 'last_name=\"Yung\"' . '&';


w/o the escapes and also:

   'oid'         => 'oid=XXXXXXXXXXX',
   'retURL'      => 'retURL=XXXXXXXXXXXXXXX',
   'last_name'   => 'Yung',


etc.

I don't want to validate/submit forms with Javascript, and my other idea is having the user confirm the details and submit to salesforce using hidden fields (but spammers can thus clone the page and spam me) while keeping the data in sessions (haven't tested this yet). Anyhelp would REALLY be appreciated, thanks!