0

Hi. I'm looking for a way to perfrom a recaptcha verification pass on an html form then, if successful, submit the detail to salesforce via their Web2Lead feature (don't have API access unfortunately).

Our salesforce integrated contact form has been subject to spam, like many others it seems, therefore I have incorporated recaptha to better verify the human touch. However, having altered the form action to use process.php (my working recaptcha verification script) I am now completely stumped as to how I then submit the detail to Web2Lead when the recaptcha check is successful. The only way I understand to do this is via the below form action which I have had to replace so as to enable the recaptcha check:

action="https://www.salesforce.com/servlet/servlet.WebToLead?encoding=UTF-8"

Can I submit the detail from the process.php file in some way or maybe have a new hidden form populated using the original filled-out detail then have this new form auto-submitted the above code as its action?

Process.php file

<?php
session_register();
	session_start();                      
	$firstname = $_POST['first_name'] ;
	$_SESSION['firstname'] = $firstname;
	$lastname = $_POST['last_name'] ;
	$_SESSION['lastname'] = $lastname;
	$email = $_POST['email'] ;
	$_SESSION['email'] = $email;
	$phone = $_POST['phone'] ;
	$_SESSION['phone'] = $phone;
	$company = $_POST['company'] ;
	$_SESSION['company'] = $company;
	$URL = $_POST['URL'] ;
	$_SESSION['URL'] = $URL;
	$description = $_POST['description'] ;
	$_SESSION['description'] = $description;	


require_once('recaptchalib.php');
$privatekey = "...PRIVKEY";
$resp = recaptcha_check_answer ($privatekey,
$_SERVER["REMOTE_ADDR"],
$_POST["recaptcha_challenge_field"],
$_POST["recaptcha_response_field"]);
if (!$resp->is_valid) {
header("location:request_submitted.php?result=fail");
die();
}

else if ($resp->is_valid) {
header("location:request_submitted.php?result=pass");
}

?>

At the moment, the recaptcha is checked and you are then directed to the above header page with success or failure notifications to the user which is great !)()! (free sarcmark!). However, with no info now ending up in salesforce, my form pretty much of 'zero use to my business'. Doh!

Any help or guidance will be really appreciated. TIA

3
Contributors
3
Replies
4
Views
7 Years
Discussion Span
Last Post by eerlewein
0

Why not put original mail process code between:

else if ($resp->is_valid) {
//....mail process code goes here...before re-direction
header("location:request_submitted.php?result=pass");
}

The mail code itself, should not have any other redirection functions. As the line header("location:request_submitted.php?result=pass"); won't be called from the new page, unless the new page includes that line of code.

0

Thanks for the suggestion, however a mail function here is no good for me. Salesforce Web2Lead can only accept info from a form with the action set as below:

<form action="https://www.salesforce.com/servlet/servlet.WebToLead?encoding=UTF-8" method="POST">

Is there somethiing else I could use at this success point in the script so as to regenerate the form and its detail with the above salesforce action set, then ideally submit the form automatically?

Thanks.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.