Using webhooks, you can instantly post your form submission data to a server-side script on your website. This means you’re able to send your new leads to a database, bespoke CRM, or even use form submission data to instantly display a personalised quote or report.

To post form submission data to an external URL using webhooks, go to the call to action section in the form builder. Scroll down to the additional settings and switch the toggle 'Post submission to webhook URL’ and enter the URL that you want your form data sent to. This will be the URL where your server-side script is located.

Now, when a user submits this form, each input value in the form will be sent to your webhook URL using the HTTP GET method.

From here, you can do whatever you wish with the data in the server-side script. Both GET and POST are treated as $_GET and $_POST. These are superglobals, which means that they are always accessible, regardless of scope – and you can access them from any function, class or file.

$_GET is an array of variables passed to the current script via the URL parameters. GET has a limit on the amount of information that can be sent (2,000 characters). In the example server-side script below, we will email the posted form data to a test email account.

Leadformly Posted to URL”;
        $message .= “ Title : “.$_GET[‘form-title’].” ”;
        $message .= “ Fullname : “.$_GET[‘form-fullname’].” ”;
        $message .= “ Email : “.$_GET[‘form-email’].” ”;
        $header = “From:[email protected] \r\n”;
        $header .= “MIME-Version: 1.0\r\n”;
        $header .= “Content-type: text/html\r\n”;
        $retval = mail ($to,$subject,$message,$header);
        if( $retval == true ) {
           echo “Message sent successfully…\n”;
        }else {
           echo “Message could not be sent…\n”;
        }
?>

As you can see above, the Leadformly form posts the variables form-title, form-fullname and form-email to yourscript.php. We then create a message string with these values and then send that as an email to ‘[email protected]’. You can find the names of the posted form variables by looking at the posted URL query string to yourscript.php. As you can see below, the first question mark is used as a separator and is not part of the query string. Please note that query strings are URL encoded.

URL encoding is the process of converting a string into a valid URL format. Valid URL format means that the URL contains only what is termed “alpha | digit | safe | extra | escape” characters. URL encoding is normally performed to convert data passed via HTML forms, because such data may contain special character, such as “/”, “.”, “#”, and so on, which could either: a) have special meanings; or b) is not a valid character for a URL; or c) could be altered during transfer. For instance, the “#” character needs to be encoded because it has a special meaning of that of an HTML anchor. The character also needs to be encoded because is not allowed on a valid URL format. Also, some characters, such as “~” might not transport properly across the internet.

In our example posted URL you can see that:

  • The character has been URL encoded as “+”. The character can either be encoded as + or %20;
  • The & character has been URL encoded as “%26”. The & character separates our variables.

The variable form-fullname with the value Adam+Wise is actually Adam Wise. Adam+Wise could equally be posted as Adam%20Wise.

Webhooks also work with conditional logic. This means that you can post form submission data to different webhook URLs depending on how your leads have responded to certain questions.

Did this answer your question?