You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+44-35Lines changed: 44 additions & 35 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,50 +1,59 @@
1
1
<palign="center">
2
-
<h1 align="center">Form2email</h1>
3
-
<br>
2
+
<h1 align="center">Static forms FormHandler library</h1>
4
3
</p>
5
4
6
-
This library allows you rapidly implement contact forms on your site.
5
+
Small library to validate simple html forms data and send requests to email.
6
+
Furthermore you can write your own "handler" to process valid data, for example if you need to save
7
+
it through API to a 3d-party service like Mailchimp, SalesForce, CRM system, etc.).
7
8
8
-
## 1. Installation
9
+
## Why FormHandler
9
10
10
-
### 1.1 Install via Composer (preferable)
11
+
It's very easy to find some ready-to-use solution to process a contact form. Usually this is pure PHP
12
+
script, which collect data and send email with php `mail()` function. It's not bad, but you can find
13
+
numerous problems with such scripts:
11
14
12
-
The recommended way to install Form2email is through
13
-
[Composer](http://getcomposer.org).
15
+
*`mail()` function can be blocked on production server, because it's not secure. Also it's often goes to SPAM folder, when you use `mail()` function.
16
+
* You need to validate, that the data is valid. Manual validation of the `$_POST` array is time consuming and require knowledge of PHP, RegExp's knowledge etc.
14
17
15
-
If you do not have [Composer](http://getcomposer.org/), you may install it by following the instructions
16
-
at [getcomposer.org](http://getcomposer.org/doc/00-intro.md#installation-nix).
18
+
We decide to create small library, which fix all these issues, so to process a form you need:
17
19
18
-
You can then install Form2email using the following command:
20
+
* set validation rules with simple configuration array
21
+
* set your Mail settings (SMTP settings OR Mandrill API key)
22
+
* set your message params (From, To, Subject, Body template)
19
23
20
-
~~~
21
-
1. Create folder
22
-
2. Create composer.json file (if it doesn't exist) with json record:
24
+
And that's it!
23
25
24
-
{
25
-
"require": {
26
-
"monolog/monolog": "1.0.*"
27
-
}
28
-
}
26
+
## Requirements
27
+
28
+
* PHP 7.0+
29
+
*[Composer](http://getcomposer.org/)
30
+
31
+
## Usage
32
+
33
+
Imagine you have simple html website with a contact form and you want to process it. We will guide you
34
+
through the whole process of creating PHP script to process a form request.
29
35
30
-
3. composer create-project
36
+
### Init your environment
31
37
32
-
4. composer require justcoded/form-handler
33
-
~~~
34
-
### 1.2 Install by download directly (alternative)
38
+
We suggest to create separate folder to place code into it. Let's call it `form`.
39
+
File structure will looks like this:
40
+
41
+
|- /form/ # folder for our code
42
+
|- contact.php # simple HTML page with a form
43
+
44
+
Inside `/form/` folder we need to create `composer.json` file to set our library requirement:
0 commit comments