<< Return to help center
Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.

Tutorial - Integrating a Web Form with Less Annoying CRM

This article explains how to send information from a simple HTML web form directly into Less Annoying CRM using our API. We take a very simple approach and assume that you know very little about web development. If you're an experienced developer, you'll probably want to add additional functionality such as field validation and error handling, but those things are ignored in this tutorial so that we can keep it as easy as possible. Our API can handle a lot more than we show here, and you can learn all about the full functionality from the main API Docs.

This tutorial uses PHP as the programming language. If you're more familiar with a different language, it shouldn't be too hard to translate our code here into any other web language.

Step 1: Generate your API Token

Before you can use our API, you need to enable it by logging in to your Less Annoying CRM account and going to the developer API settings page. If you haven't already, click the "Generate a new API Token" button. This will give you a User Code and API Token, both of which you'll need later in this tutorial.

Step 2: Make a web form with HTML

If you have any experience with HTML, you probably already know how to build a form into your web page. If you don't, here is a very simple example of how you make a web form. You can just copy this code as a new file on your web server, or add everything inside the "body" tag into an existing web page.

CODE:https://gist.github.com/tilikang/55af46962eaa83658dc23031fd31e687.js

Once you save this file on your server, you should be able to view it. For example, if you name the file form.html and put it in your home directory, you should be able to access it by going to http://YourWebsite.com/form.html

Step 3: Send the form data to the CRM

Notice that the form tag from the file you created in step 2 has an "action" attribute which is "process.php". That means that when this form is submitted, it will send the user to a different file called process.php. That's what we'll create now. Just make a new file called process.php and put it in the same directory as the html form you made in step 2. Here's what the code should look like:

CODE:https://gist.github.com/tilikang/61dae87cab9f880e967766b8b7063ca8.js

There a few things you'll need to know about this file. First, at the very top, you'll see $UserCode and $APIToken variables. You'll need to plug in the settings you got in step 1 there.

Also, if you're not familiar with PHP, you can use $_REQUEST to get any of the variables that were submitted in the form. For example, in the form from step 2 there is an input called "ContactName", and you can see on line 21 where we get that value by calling $_REQUEST['ContactName']. If you want to add any additional fields to the HTML form, that's how you can get their values in PHP.

Finally, the comment in line 54 explains that you can do many other things with the API after creating the contact. Take a look at the main API docs for instructions on all the different functions we support. You can see a more advanced example of this same PHP file which first checks to see if a contact already exists before adding them to the CRM here.

Step 4: Make a confirmation page

The "header" line near the end of the PHP file sends the visitor to a file called confirm.html which will tell them that the form was submitted. Create this file on your web server in the same directory as the other files. You can make this file say whatever you want, but here's an example of what you might put:

CODE:https://gist.github.com/tilikang/aa15f1d017aa1b1ef372aca6f6a806a0.js

That's it! You just made a web form in HTML, a PHP script to process the form and send it directly into Less Annoying CRM, and a confirmation page to let the visitor know that the form was submitted. From here you can style the forms, add more fields, and much more. Good luck!

Next up:
Advanced API tutorial - checking for duplicates before entering a contact
Keywords:
API, web form, tutorial, coding, programming
How do I can you are you able to can I how to is it possible