Project

Profile

Help

Contact Forms with Planio » History » Sprint/Milestone 3

Thomas Carney, 10/25/2016 02:13 PM

1 1 Thomas Carney
# How to Set Up Contact Forms via the Redmine API at Planio
2
3 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.
4 1 Thomas Carney
5 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.
6 1 Thomas Carney
7
First, we’re going to build a simple form with an action attribute that submits the form to Planio via the POST HTTP method.
8
9
~~~html
10
<form action="https://example.plan.io/track" method="POST">
11
12
Then, we’ll add input fields for a name, email, email subject, and the description:
13
14
  <label for="name">Your name:</label>
15
  <input name="name" id="name" type="text" />
16
17
  <label for="mail">Your email address:</label>
18
  <input name="mail" id="mail" type="email" />
19
20
  <label for="subject">Subject:</label>
21
  <input name="subject" id="subject" type="text" />
22
23
  <label for="description">Your message:</label>
24
  <textarea name="description" id="description"></textarea>
25
~~~
26
27
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:
28
29
~~~html
30
  <input name="project" type="hidden" value="example-project" />
31
~~~
32
33
Then, we add the submit input field:
34
35
~~~html
36
  <input type="submit" value="Submit request" />
37
~~~
38
39
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.
40
41
Here’s the honeypot field along with some CSS:
42
43
~~~html
44
<!-- CSS to hide honeypot field -->
45
<style media="screen">#url { display:none; }</style>
46
  <input name="url" id="url" type="text" />
47
~~~
48
49
So, pulling it all together, our form will look like this:
50
51
~~~html
52
<!-- CSS to hide honeypot field -->
53
<style media="screen">#url { display:none; }</style>
54
55
<form action="https://example.plan.io/track" method="POST">
56
57
  <label for="name">Your name:</label>
58
  <input name="name" id="name" type="text" />
59
60
  <label for="mail">Your email address:</label>
61
  <input name="mail" id="mail" type="email" />
62
63
  <label for="subject">Subject:</label>
64
  <input name="subject" id="subject" type="text" />
65
66
  <label for="description">Your message:</label>
67
  <textarea name="description" id="description"></textarea>
68
69
  <input name="project" type="hidden" value="example-project" />
70
  <input name="url" id="url" type="text" />
71
  <input type="submit" value="Submit request" />
72
73
</form>
74
~~~
75
76
When someone fills out this form, the message will show up in Planio as an issue as you can see here:
77
78
![](contact-form-message-as-issue.png)
79
80
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/) .