Project

Profile

Help

Contact Forms with Planio » History » Revision 2

Revision 1 (Thomas Carney, 10/25/2016 02:06 PM) → Revision 2/62 (Thomas Carney, 10/25/2016 02:13 PM)

# How to Set Up Contact Forms via the Redmine API at Planio 

 Today we’re going to look at using the Redmine API at Planio to set up a contact form that sends messages directly to Planio without server-side scripting. 

 You Planio is a project management tool and issue tracker with a wide variety of features. For example, it includes issue tracking, Gantt charts, repository hosting, wikis and more. Planio is based on Redmine, an open source project management tool. 

 We’ve documented the Redmine API at Planio with code examples and ideas for using the API. 

 One of those ideas is a contact form. Usually, you need a server-side script to handle contact form requests. And then you need to route those requests to an email address or customer support system. 

 Here we’ll look at how you can send contact form requests directly to Planio, Planio without any server-side scripts, as Planio will accept an unauthenticated POST request with application/x-www-form-urlencoded form data. 

 First, we’re going to build a simple form with an action attribute that submits the form to Planio via the POST HTTP method. 

 ~~~html 
 <form action="https://example.plan.io/track" method="POST"> 

 Then, we’ll add input fields for a name, email, email subject, and the description: 

   <label for="name">Your name:</label> 
   <input name="name" id="name" type="text" /> 

   <label for="mail">Your email address:</label> 
   <input name="mail" id="mail" type="email" /> 

   <label for="subject">Subject:</label> 
   <input name="subject" id="subject" type="text" /> 

   <label for="description">Your message:</label> 
   <textarea name="description" id="description"></textarea> 
 ~~~ 

 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: 

 ~~~html 
   <input name="project" type="hidden" value="example-project" /> 
 ~~~ 

 Then, we add the submit input field: 

 ~~~html 
   <input type="submit" value="Submit request" /> 
 ~~~ 

 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. 

 Here’s the honeypot field along with some CSS: 

 ~~~html 
 <!-- CSS to hide honeypot field --> 
 <style media="screen">#url { display:none; }</style> 
   <input name="url" id="url" type="text" /> 
 ~~~ 

 So, pulling it all together, our form will look like this: 

 ~~~html 
 <!-- CSS to hide honeypot field --> 
 <style media="screen">#url { display:none; }</style> 

 <form action="https://example.plan.io/track" method="POST"> 

   <label for="name">Your name:</label> 
   <input name="name" id="name" type="text" /> 

   <label for="mail">Your email address:</label> 
   <input name="mail" id="mail" type="email" /> 

   <label for="subject">Subject:</label> 
   <input name="subject" id="subject" type="text" /> 

   <label for="description">Your message:</label> 
   <textarea name="description" id="description"></textarea> 

   <input name="project" type="hidden" value="example-project" /> 
   <input name="url" id="url" type="text" /> 
   <input type="submit" value="Submit request" /> 

 </form> 
 ~~~ 

 When someone fills out this form, the message will show up in Planio as an issue as you can see here: 

 ![](contact-form-message-as-issue.png) 

 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/) .