Project

Profile

Help

Contact Forms with Planio » History » Sprint/Milestone 7

Thomas Carney, 10/25/2016 03:21 PM

1 3 Thomas Carney
Today we’re going to look at setting up a contact form that sends messages directly to Planio where they'll appear as issues in the Help Desk.
2 1 Thomas Carney
3
{{TOC}}
4 5 Thomas Carney
5 7 Thomas Carney
## HTML Form
6 5 Thomas Carney
7 2 Thomas Carney
You can send contact form requests directly to Planio, as Planio will accept an unauthenticated POST request with application/x-www-form-urlencoded form data.
8 1 Thomas Carney
9
First, we’re going to build a simple form with an action attribute that submits the form to Planio via the POST HTTP method.
10
11
~~~html
12
<form action="https://example.plan.io/track" method="POST">
13
14
Then, we’ll add input fields for a name, email, email subject, and the description:
15
16
  <label for="name">Your name:</label>
17
  <input name="name" id="name" type="text" />
18
19
  <label for="mail">Your email address:</label>
20
  <input name="mail" id="mail" type="email" />
21
22
  <label for="subject">Subject:</label>
23
  <input name="subject" id="subject" type="text" />
24
25
  <label for="description">Your message:</label>
26
  <textarea name="description" id="description"></textarea>
27
~~~
28
29
A Planio account can have multiple projects, so we need a way to assign this message to a particular project in Planio. Therefore, we’ll add a hidden input field with the value set to the name of the project you want to forward the issue:
30
31
~~~html
32
  <input name="project" type="hidden" value="example-project" />
33
~~~
34
35
Then, we add the submit input field:
36
37
~~~html
38
  <input type="submit" value="Submit request" />
39
~~~
40
41 7 Thomas Carney
## Add a Honeypot Field
42 1 Thomas Carney
43 6 Thomas Carney
Forms are frequently the target of spambots that will send messages to any form they can find online. One strategy for dealing with spam bots is to add an additional input field to the form called a honeypot field. Then, you hide the form field using CSS. If that input field is filled out, which spambots usually do, then the message is discarded as spam - hence the name honeypot field.
44 5 Thomas Carney
45 1 Thomas Carney
Here’s the honeypot field along with some CSS:
46
47
~~~html
48
<!-- CSS to hide honeypot field -->
49
<style media="screen">#url { display:none; }</style>
50
  <input name="url" id="url" type="text" />
51
~~~
52
53
So, pulling it all together, our form will look like this:
54
55
~~~html
56
<!-- CSS to hide honeypot field -->
57
<style media="screen">#url { display:none; }</style>
58
59
<form action="https://example.plan.io/track" method="POST">
60
61
  <label for="name">Your name:</label>
62
  <input name="name" id="name" type="text" />
63
64
  <label for="mail">Your email address:</label>
65
  <input name="mail" id="mail" type="email" />
66
67
  <label for="subject">Subject:</label>
68
  <input name="subject" id="subject" type="text" />
69
70
  <label for="description">Your message:</label>
71
  <textarea name="description" id="description"></textarea>
72
73
  <input name="project" type="hidden" value="example-project" />
74
  <input name="url" id="url" type="text" />
75
  <input type="submit" value="Submit request" />
76
77
</form>
78
~~~
79 5 Thomas Carney
80
## Example Contact Form Message as an Issue in Planio
81 1 Thomas Carney
82
When someone fills out this form, the message will show up in Planio as an issue as you can see here:
83
84
![](contact-form-message-as-issue.png)
85
86
That’s just one of the examples of how you can use the Redmine API at Planio to streamline your processes. You’ll find more examples and documentation in our [Redmine API documentation](https://plan.io/api/) .