Modal Demo

How To Easily Put A Form On Your Website

How To Easily Put A Form On Your Website

Carlos Augusto Avatar
Carlos Augusto Avatar

Disclosure: Our content is reader-supported, which means we earn commissions from links on Crazy Egg. Commissions do not affect our editorial evaluations or opinions.

This guide will teach you how to use the best tools to quickly create forms and embed them on your website, whether itโ€™s a plain HTML / PHP website or a WordPress website.

Weโ€™ll begin by using some third-party companies, like Survey Monkey and Google Forms, to quickly create a form as fast as possible. We wonโ€™t spend any time customizing colors or anything like that. This is a how to get it done QUICKLY guide. Then weโ€™ll show how to create your own form either in WordPress or in straight PHP code. The final section is about getting that form on your site.

Creating a Form in Survey Monkey

First, go to surveymonkey.com and log in to your account, or sign up for a new account. If prompted, fill out the initial questions so that you get to the first screen in their system (see figure below). You can then either choose to start from scratch, or choose a template. Choose the first template as shown in the figure, so that we can show you how to embed it on your website as quickly as possible ๐Ÿ™‚

Quick view

Next, youโ€™ll be presented with a bunch of choices on how to distribute your form to the world. Letโ€™s choose, of course, โ€œembed on websiteโ€ (see figure below). Later you can try out the other distribution methods.

Embed on website

Next, youโ€™ll want to choose โ€œEmbedded Surveyโ€ (see figure below).

Embedded survey

Finally, youโ€™ll see the javascript code that will activate your new survey form! Click once on the block of code and its text will highlight as depicted in the figure below. When itโ€™s highlighted, just hit Ctrl+C (or Cmd+C on Apple PCs) to copy it.

We will be pasting this code into your website in the Embedding section below, and weโ€™ll cover doing it on both a plain HTML5 website and a WordPress website!

Installation code

Creating a Form in Google Forms

In order to access Google Forms, youโ€™ll first need a free Gmail account. If you donโ€™t have a Gmail account that isโ€ฆ unfortunate. But even if you donโ€™t want to have a Gmail address for email purposes, you can create a free account just for the sake of logging into all of Googleโ€™s myriad of services. This is a prerequisite for this section. Iโ€™ll assume you are able to log into Google Drive with your Google Account username, which is most likely your Gmail address.

First, go to this URL: https://drive.google.com. Once youโ€™re logged into Google Drive, youโ€™ll see the following screen shown below. Youโ€™ll want to click on โ€œNEW,โ€ then โ€œMore,โ€ then โ€œGoogle Formsโ€ (as depicted in red in the figure below.)

New more google form

And voila! You are instantly taken to a form, ready to customize, as shown in the next figure below. No setup process. No โ€œwizard.โ€ I really love this part of Google Forms. You instantly go straight to the matter at hand. And you simply click on the areas you want to edit and type right into the screen. Where it says โ€œUntitled Form,โ€ just click on it and give it a name.

Untitled question

Next, click the โ€œSendโ€ button, shown in red in the next figure. Notice also the sample names I gave to all the form sections just by clicking on them and typing.

Send

Finally, you will reach the โ€œSend formโ€ dialog box, where, as shown in the red highlights, youโ€™ll first want to click on the โ€œ< >โ€ button to access the HTML embed code, then just click on the โ€œCOPYโ€ button at the lower right of this dialog. This will copy the embed code to your clipboard.

copy

Thatโ€™s it! Youโ€™ll paste it into your website in the Embedding section below, and weโ€™ll cover doing it on both a plain HTML5 website and a WordPress website!

Creating a Form in MailChimp

First, go to MailChimp and log in, or create a free account. MailChimp is totally focused on email collection forms only. That means weโ€™ll be creating a simple form that visitors to your website use to sign up to your list, after which you can send them all weekly or monthly newsletters, updates, etc. MailChimp is one of the best, cleanest, and easiest to use email list providers out there.

Once youโ€™ve logged in, youโ€™ll want to click on โ€œListsโ€ on the upper left menu (see screen below). Then click on the โ€œCreate Listโ€ button to the right. Youโ€™ll be taken to a simple form you must fill out to create your mailing list. Fill this out and click โ€œNextโ€ to finish this step.

Lists

Now you can see your new list on the screen. Scroll down and click on โ€œCreate a signup formโ€ to proceed (see screen below).

Create a backup form

On the next screen, youโ€™ll want to click on the โ€œSelectโ€ button to the right of โ€œEmbedded Formsโ€ (see screenshot below).

Select

Finally, youโ€™ll reach the form customization screen (see below)! For the purposes of this guide, letโ€™s just leave it as is. Scroll down and click on the code (highlighted in blue in the screenshot) and copy it to your clipboard.

Copy paste onto your site

Thatโ€™s it! Youโ€™ll paste this code into your website in the Embedding section below, and weโ€™ll cover doing it on both a plain HTML5 website and a WordPress website!

Creating a Form in WordPress

Hereโ€™s a quick tutorial on the quickest and easiest way to create a form in WordPress. This guide assumes you already have a WordPress site set up. Weโ€™ll start at the dashboard, the screen you see upon logging into your WordPress admin area. First, on the left sidebar menu, click on โ€œpluginsโ€ (as highlighted in red below).

We recommend WPForms or Formidable Forms for WordPress.

Plugins

On the very next screen, make sure you click the blue โ€œAdd Newโ€ button (as highlighted in red below) to go to the correct plugin installation screen.

Add new plugins

Next, type โ€œWPFormsโ€ in the box highlighted below.

Search plugins

The first box that appears will be for โ€œWPForms,โ€ one of the best WordPress form plugins available today. Click on the โ€œInstall Nowโ€ button as highlighted, and it will change into a blue โ€œActivateโ€ button. Click on that as well :).

Install now

Youโ€™ll immediately be taken to the WPForms intro screen, as shown below. Click the big โ€œCreate Your First Formโ€ button as shown.

Create your first form

Next, give the form a title. I chose โ€œSay Helloโ€ for mine. Then click โ€œCreate a simple contact formโ€ as highlighted.

Create simple contact form

Youโ€™ll immediately be taken to a screen showing your form, including first name, last name, and email. Letโ€™s leave everything as is for now. You can go and edit things later. For now, click on the โ€œEmbedโ€ button as highlighted below, and the pop-up window displayed will appear. Iโ€™ve highlighted the embed code in blue but you donโ€™t even have to copy this code (Youโ€™ll see why in a few more steps). Just click the โ€œxโ€ to close the window, and then the big โ€œxโ€ at the top right to get out of the WPForms interface and get back to the normal WordPress admin area.

Embeded

Now that youโ€™re back in normal WordPress mode, click on โ€œPagesโ€ as shown below, in the left sidebar menu. This is where weโ€™ll temporarily activate the form, for now.

Select pages

Next, click โ€œAdd newโ€ at the top left (as shown below).

Add new

Now youโ€™ll be in the page editing screen. You probably wonโ€™t see the big purple โ€œDivi Editorโ€ buttons I have but ignore that. Youโ€™ll see the highlighted button โ€œAdd Form.โ€ This button exists because you installed the WPForms plugin (WordPress plugins can add little menus and buttons all over the place, in fact.). Click on it.

Select add forms

Youโ€™ll see a pop-up with our โ€œSay Helloโ€ form showing as the first choice in the drop-down. Just click the blue โ€œAdd Formโ€ button at the lower right of this window to move on.

Insert form say hello

Now youโ€™ll see the shortcode text that you didnโ€™t have to copy earlier automatically inserted into the editing area :). Now just click the blue โ€œPublishโ€ button as highlighted below.

Publish

Once thatโ€™s done, youโ€™ll see a box at the top of your screen that says โ€œPage published. View pageโ€. Click on that link (as shown) to view your brand new live form!

View page

Yep, a basic form. Looks good! If you fill it out and click submit, it would be emailed to the email specified as the WordPress administratorโ€™s email address. Letโ€™s go back and double check that you have this the way you want it. Close out of your live form and go back to the WordPress admin area.

Test form

Again, on the left sidebar menu, click โ€œUsersโ€ (as shown popped out in blue below). The first user is the admin account, and please ensure the email is correct. If not, or if youโ€™re not the admin, you can go back to the WPForms settings screen by clicking on โ€œWPFormsโ€ in the left side menu (just three above โ€œUsersโ€ ;-).

Users

Thatโ€™s it! Be sure to fill out your live form and make sure it goes to your specified email address correctly. You can add the form to any page or blog post by clicking that โ€œAdd Formโ€ button on any page or post editing screen.

Whatโ€™s great about WPForms is that with the pro version, you can get plug-ins for MailChimp and lots of other marketing tools. I also find that its plugin interface is really sleek and nicely designed. Gravity Forms and Ninja Forms are also two other well-known, wonderful WordPress form plugins you can try out as well.

Creating a Form in PHP

This section will outline the basic steps of creating a form in straight PHP for your website. This is pure HTML and PHP code โ€” no WordPress, no embedding a third party form, just pure coding! This is by far the most complicated method, and the steps in this section might well generate many more questions for you than there are steps! Still, almost any good content creator, marketer, or basic website owner should have a basic familiarity with these tools and this method of editing a website.

Weโ€™re going to start with a basic Google search for โ€œphp contact form.โ€ Google automatically suggested I add โ€œwith validationโ€ to my search, and as a web developer I agreed (see image below) โ€” validation basically means the little messages that pop-up when you leave a form field blank, for example, which says โ€œthis field cannot be blankโ€.

In the red circle shown below, Iโ€™m showing the search result on GitHub, which is a huge community where typically great developers share their code. The top engineers in the world who earn six-figure salaries showcase their work on GitHub. Furthermore, any project on GitHub can be downloaded without any annoying email subscription pop-ups. Letโ€™s check it out!

Github google search

Once youโ€™re on GitHub, look for the green โ€œClone or downloadโ€ button on the right side of the page. Click on it to reveal a small pop-up. Click on โ€œDownload ZIPโ€ (highlighted below). If youโ€™re a seasoned developer, you might choose to clone the project into your own git repository (what GitHub is named after), but if you knew how to do that you probably wouldnโ€™t be reading this guide ;-).

Download zip

The ZIP file has downloaded into your downloads folder by now, but before we go looking for it, I must stress that you should scroll down every time youโ€™re on GitHub and read (or at least skim) the documentation for the project! This is what those aforementioned seasoned engineers would call RTFM, which is short for โ€œRead The …. umโ€ฆ Fahrvergnรผgenโ€ฆ Manualโ€ ๐Ÿ˜›

In the highlighted section below you see that you must edit the file called โ€œconfig.phpโ€ and fill in what your from and to e-mail addresses will be so that the contact form can properly send out emails. If you just rushed straight to the ZIP file first, you would end up being lost and frustrated for hundreds of hours until you threw your computer over the cliff you happened to be sitting next to while working on this contact form.

Email to receive email

In the next screen below, Iโ€™m showing the ZIP file that was downloaded to my โ€œDownloadsโ€ folder in OS X, which I use on my MacBook Pro. If I had a Windows machine, this could be in a different place, of course.

Notice inside the outer folder there are a bunch of files and a folder named โ€œcontact-formโ€ at the top of the list. Generally, this outer listing of files are very techy developer stuff and you donโ€™t need to worry about it. The file named โ€œREADME.mdโ€, for example, is actually the exact same information in the instructions on any Github project that I had you read in the previous step. So the basic pattern is that youโ€™ll take the project folder (in this case named โ€œcontact-formโ€) and just drag that into your FTP program to upload it to your website.

Downloads contact forms

Again, this step can vary wildly between Mac, Windows, Linux, and whatever FTP client you use. Iโ€™m using Mac OS X with the latest version of Transmit (version 5), possibly the best FTP client ever made! Iโ€™ve already set up a connection to my website in Transmitโ€™s settings (youโ€™ll need to know how to do this with your FTP client). But once youโ€™re in, youโ€™ll see something like the screen below, which is a listing of all my website files. Notice in the red circle below I just dragged the โ€œcontact-formโ€ folder into my FTP window and itโ€™s been uploaded to my website. (I also renamed it to โ€œ_contact-formโ€ with an underscore at the beginning of the filename so that it goes first in the list alphabetically.)

Notice also that Iโ€™m inside the โ€œcontact-formโ€ folder, which contains the โ€œconfigโ€ folder, and within that there is our special โ€œconfig.phpโ€ file. This is the one you know you have to edit if you had read those GitHub instructions above! One really cool thing about Transmit is that I am able to configure it to open any text files I double-click on directly into my text editor, Sublime Text 3 (which is one of the best code editors on the planet)! This lets me skip the whole process of downloading the file, opening the downloaded file, and then re-uploading it after editing it. Instead, it just opens right in Sublime Text (with color-coded text to boot), and when I hit Cmd+S (to save the file), it automatically re-uploads to my website!

Contact form

Below youโ€™ll see how my text editor looks. I highlighted the part we need to edit in yellow. Notice I filled in the relevant sections with my email addresses. I put my personal email address in the to section, and the from section is from a โ€œwebformโ€ address which is fine; this is just a simple contact-form test. A real setup might have used โ€œinfo@โ€ or โ€œno-reply@.โ€

Sublime text

OK! After editing that file, our contact form is finished! We can go right to the live URL: https://plu.sx/_contact-form/index.php. Notice the form looks pretty nice, and the form validation works if you try to hit send without filling everything out.

Please fill out this field

Once you fill out the form correctly, youโ€™ll get to the final screen after hitting send. The form message displays โ€œEmail sent successfully.โ€ Great!

But beware!! Just because the contact form thinks the message went out to you doesnโ€™t mean youโ€™ll get an email. Again, this step can vary wildly as there are thousands of server setups, web hosting companies, and PHP configurations that can cause any number of issues. If you actually donโ€™t get an email, youโ€™ll have to troubleshoot your server (or call your hosting company) and ask them what went wrong. Taking a look at the โ€œSimpleMail.class.phpโ€ file hiding within the โ€œcontact-formโ€ folder I can see itโ€™s using the PHP โ€œsendmail()โ€ function to handle e-mail delivery. Luckily for me, this worked fine without any further headaches and the contact-form was working fine at this point.

Simple php contact form

Thatโ€™s it! As you can see, the PHP version of this guide is very involved, wrought with potential mishaps, very hard to troubleshoot, and fraught with terror! Now you can viscerally see why companies such as MailChimp are so successful. They handle all the server setup and code on their end and just give you a simple embed code. The amount of complexity is reduced by up to 99%, and the ease-of-use increased conversely.

But if youโ€™re set on using a PHP solution, then you should be adept at completing all these steps, and you do, in the end, have ultimate control over how to customize the form and how it works. There are virtually no limits to what you can program with HTML, PHP, and Javascript. For instance, you could make your contact form email you, save the visitorโ€™s name to a separate database, and even connect to MailChimp or any of the other services we went over, all from one single click of the โ€œSendโ€ button.

Embedding a Form Into Your Website

In this section weโ€™ll cover embedding a form on your website, both in WordPress and in straight HTML.

First, choose which embed code (that we generated in one of the sections above) youโ€™ll want to use:

Here is our MailChimp embed code

Mailchimp embedded code

Mailchimp embedded code 2

Here is our SurveyMonkey embed code

Survey Monkey embed code

Here is our Google Forms embed code

Google Forms embed code

Interestingly enough, each of these services uses a different embed approach. MailChimp just gives you a plain block of HTML. SurveyMonkey gives you a block of javascript which creates the form HTML for you. And Google forms gives you an iFrame, which is like a little window directly to their website. Each of these methods requires that you either paste the code somewhere in between the <body></body> tags on one of your web pages for a plain HTML page or in the appropriate area of WordPress if youโ€™re using that. Letโ€™s review each:

Embedding Your Form in a Plain HTML Website

Youโ€™ll need to have an FTP client to access the files on your website and paste the code within. What youโ€™ll end up with is a page similar to this demo page Iโ€™ve prepared on my website.

Here youโ€™ll see the contact forms we created above, and if you choose Cmd+Opt+U in Google Chrome youโ€™ll open up the โ€œview sourceโ€ page which will display the HTML code for this page. If you read through this code youโ€™ll see how the various embed codes above were simply pasted below the pageโ€™s top <body> tag. I added a small bit of CSS to center each form in a nice box and pop them out from a gray background so itโ€™s easier for you to see them.

Embedding Your Form in WordPress

First, youโ€™ll have to be logged in to your WordPress dashboard. Again, this assumes you have WordPress set up already. So in that case, log into your WordPress admin area and weโ€™ll start by clicking the โ€œPluginsโ€ menu circled in red below. Then click the โ€œAdd Newโ€ button on the top left of the Plugins page shown below.

Note: Weโ€™re going to find and install the XYZ Snippets plugin which helps preserve HTML perfectly. If you try to paste HTML or Javascript directly into a WordPress post or page without any help from a plugin like this, you may get wonky effects because WordPress likes to add a bunch of formatting stuff automatically.

Select plugins

Now type โ€œinsert html snippetโ€ into the plugin search field and youโ€™ll see the screen below. Click โ€œinstall nowโ€ (circled in red below), then immediately after click โ€œActivate.โ€

Install now plugins

Once youโ€™ve done this, youโ€™ll have the โ€œXYZ Snippetsโ€ menu in the left side-menu in WordPress. (See circled below.) Click on that to get to the plugin page, then click the blue โ€œAdd New HTML Snippetโ€ button at the top of the page.

xyz html

Now in this next screen below, letโ€™s just call the snippet โ€œGoogle Formsโ€ and letโ€™s just paste the Google Forms HTML code we showed above into the form. Finally, just click โ€œCreate.โ€

Google forms code

Now youโ€™ll see the screen below, with the HTML snippet shortcode highlighted in blue below. You could select it here and copy it, but you wonโ€™t have to. Letโ€™s just move on.

Snippet short code

Click on the โ€œPagesโ€ left side menu option as shown below, then either click โ€œAdd Newโ€ at the top of the screen or edit an existing page. For now, Iโ€™ll edit the โ€œtest formโ€ page that we created in the section above.

Wordpress pages

Now, check for the area I circled in red below. Again, WordPress plugins can create new buttons throughout the system. Remember, when we added the WPForms plugin above, we got the new โ€œAdd Formโ€ button, and now we have this new โ€œInsert HTML snippetโ€ button. Youโ€™ll see the one snippet we created, โ€œGoogle Formโ€ showing in the menu. Click on that and the shortcode you didnโ€™t need to copy earlier automatically gets added to the editing window below! I decided to move the Google Form shortcode to the top of the window for this demo (above the WPForms shortcode we created earlier on). Finally, click the blue โ€œUpdateโ€ button, also circled in red below.

Google forms update

Finally, click โ€œView pageโ€ circled in red below!

Select view page

This will take you to your live WordPress page with, voila! Your Google Form embedded nicely within. Hereโ€™s the live URL: https://carlosaugusto.net/test-form.

Carlos test form


Scroll to Top