It's easy to create a web form using HTML. However, after the user submits the form, you need to process the data that is sent to your server. This requires the use of a server-side language like PHP.
This article will explain: what form processing involves, why using a simple PHP script is problematic, and an easier way to process you form.
Suppose you create a simple contact form like this:
When someone fills out this form, you'll want to email the message to your inbox. Processing the form must be done by your server and is actually a lot of work. You need to:
- Verify that all fields have been entered correctly
- Is the email address a valid email address?
- Are any required fields empty?
- Filter out SPAM messages
- Turn the field results into an email message
- Send the email message to your inbox
The Downsides of PHP Mail Scripts
As you can imagine, doing all of this requires quite a bit of PHP logic. Instead of writing this yourself, you might find a script online. But, by using someone else's PHP code that you do not understand, you'll be opening your site up to potential security vulnerabilities.
Moreover, standard shared hosting servers aren't intended to send email messages. While a PHP script on your server can technically email a message, there is no guarantee that the message will ever arrive at its intended destination. Since your server is small and shared with others, email providers like Gmail are very suspicious of it. To them, it looks very similar to small anonymous servers trying to send SPAM. Therefore, they may filter it out the message before it gets to your mailbox.
An Easy Way to Process Forms
As an alternative, you can use a form processing like FormDen. The idea is simple: instead of sending the form data to your own server, you send it to the FormDen server. You tell FormDen what fields to expect and where to send the data. FormDen validates the fields, filters out SPAM, and emails the messages for you.
How does it work?
- Create a FormDen account and you'll be given a unique url that corresponds to your form
- Add action="unique_url" to the form on your webpage
formden.js) to your webpage
To learn more, you can check out a detailed guide in our documentation, or sign up for a account to try it for yourself.