Adding a “Verify email” field to your contact form

The Turning Gate Pages and Client Response Gallery both use the free FormToEmail script to process and email contact forms. It’s really slick. Using FormToEmail, your email address isn’t visible to email address mining bots so you don’t get spammed. Well, not as much as you would otherwise.

I just found out that if someone is using Safari, they can accidentally send the contact form without filling out the email field. In all other browsers you’ll get a message telling you that you need to fill that field out.
And the form isn’t actually sent either, so there’s that.

The way around this is to buy FormtoEmailPro and configure it so that the email field is required to be filled out. (Matt just updated the CRG so that an error message will appear if the name or email fields are empty)

To upgrade to FormToEmailPro for TTG Pages or CRG, take a look here.

______________________________________________

To prevent a form with an empty email field from being sent in the first place, open FormToEmailPro.php with a text editor. I’m using Notepad++ for Windows, which is much more versatile than Windows Notepad.

On line 269 there is a “required fields check.” Change the value to ‘1’ to activate it. Below, on line 277, fill in the required fields. It’s already populated with ‘name’, ’email’, and ‘message’ so edit as you need. This works in all browsers I’ve tested.

Note: there are other things in FormToEmailPro you might need/want to fill out, so take a look around.

When you save the file, be sure to save it as FormToEmail.php because that’s what’s needed on your site. Now upload the file to your site. If this is for a standard Pages installation, upload it to the /resources/php/ folder. Set your FTP program to overwrite the existing file.

Here’s another quirk. In the  free FormToEmail script used by TTG plugins, the script actually checks to see if the email address is valid. It’s supposed to spit out an error message if it isn’t valid.
I deliberately entered an invalid email address to test it and what happened is that it looked, from a site visitor’s perspective, that the email was sent. But I never received the email because the email address was invalid. So the FormToEmail script didn’t send an email. I’m not sure why the error message that’s supposed to pop up isn’t doing so.

But the point is, someone could fill out your contact form and screw up their email address. Then, thinking that they’re sending you an email telling you they want to pay you lots and lots of money for a print or a workshop or something, they don’t get a reply because you never got the email and now they think you’re just the rudest you-know-what in the world.

But there’s a solution to that too. In the FormToEmailPro.php script, on line 261 you’ll see $confirm_email_address = 0; Change that 0 to a 1 and the script will compare two email fields to make sure they match.

There’s a catch to this though. The TTG contact page spits out a form that has only one email address field. So you need to add another. Line 257 of the FormToEmailPro script gives you instructions. But basically, what you need to do is to simply copy the section of code from the exported contact.php page that has to do with the email field. It looks like this:

<fieldset>
<label for=”field2″>Email</label>
<div><input id=”field2″ name=”email” type=”text” size=”30″ tabindex=”2″ required /></div>
</fieldset>

(Note: you need to export Pages first, then navigate to where you saved it on your hard drive and open the contact.php file with your text editor.)

Now paste this right below the section you just copied and change name=”email” to name=”email2″ and change the label to “Confirm Email” as I’ve done below.

<fieldset>
<label for=”field2″>Email</label>
<div><input id=”field2″ name=”email” type=”text” size=”30″ tabindex=”2″ required /></div>
</fieldset>

<fieldset>
<label for=”field2″>Confirm Email</label>
<div><input id=”field2″ name=”email” type=”text” size=”30″ tabindex=”2″ required /></div>
</fieldset>

When I did this, my contact form looked just as I expected. (Go take a look) I did wonder though about duplicating “field2” in the pasted code for the second email field. When you look at the form’s code in the contact.php file in a text editor, you’ll see “field1” through “field4”. So I changed the duplicated “field2” to “field5”. It still works so I’m a happy camper.

<fieldset>
<label for=”field5″>Confirm Email</label>
<div><input id=”field5″ name=”email” type=”text” size=”30″ tabindex=”2″ required /></div>
</fieldset>

If an identical invalid email address is put into both fields it still appears to the sender that the email has been sent. No error page pops up. Not sure why. But at least this way I’m significantly reducing the likelihood that someone using the form will enter an incorrect email address.

You’ll need to purchase FormToEmailPro to get these features, but it’s not expensive and I think having this feature is worth it. Sure is a lot less painful than losing a potential customer.

UPDATE: Matt has just released an updated version of the Client Response Gallery. In it is the ability to use PHPlugins to modify and customize your Contact Form. Using my method above, you’d have to edit the contact form in every Client Response Gallery you create. And if you’re outputting many galleries, this becomes at the very least, impractical. So this additional capability of the CRG is a welcome one. Read about the update here.

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.


Newsletter

Take a look through the Newsletter archives or subscribe.

Keep up to date on workshop offerings, print sales, photo tips, puppy pictures and more!



Affiliate links below! If you buy after clicking these links, I get a taste. Win-win!

Maven Filters


High quality magnetic photo filters that will change your photographic life!
Affiliate link.


Topaz Labs

Awesome plug-ins to reduce noise, sharpen, and resize images. Affiliate link!


Think Tank

Affiliate link!

Lightroom Classic The Missing FAQ

Highly recommended. This is my go-to Lightroom book. Click on the book image. Affiliate link!